Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to close the log file before packing when app crashed #434

Closed
mooons opened this issue May 6, 2020 · 0 comments
Closed

Need to close the log file before packing when app crashed #434

mooons opened this issue May 6, 2020 · 0 comments
Labels
Bug Issues which are bug reports Confirmed Confirmed issues

Comments

@mooons
Copy link

mooons commented May 6, 2020

Otherwise the resulting zip file will be corrupted. :(

[18:42:52.770 FTL] Exception Occurred  (at SoundSwitch.Program.HandleException)
System.IO.IOException: The process cannot access the file 'C:\Users\u\AppData\Roaming\SoundSwitch\Logs\soundswitch20200503.log' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.Compression.ZipFileExtensions.DoCreateEntryFromFile(ZipArchive destination, String sourceFileName, String entryName, Nullable`1 compressionLevel)
   at System.IO.Compression.ZipFile.DoCreateFromDirectory(String sourceDirectoryName, String destinationArchiveFileName, Nullable`1 compressionLevel, Boolean includeBaseDirectory, Encoding entryNameEncoding)
   at SoundSwitch.Program.HandleException(Exception exception) in C:\Users\Antoine\source\repos\SoundSwitch\SoundSwitch\Program.cs:line 245
   at SoundSwitch.Program.Main() in C:\Users\Antoine\source\repos\SoundSwitch\SoundSwitch\Program.cs:line 172

(From #427 (comment))

Solution: Log.CloseAndFlush() before ZipFile.CreateFromDirectory.

@Belphemur Belphemur added Bug Issues which are bug reports Confirmed Confirmed issues labels May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues which are bug reports Confirmed Confirmed issues
Projects
None yet
Development

No branches or pull requests

2 participants