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

ZipFile.Save() unhandled exception #10

Open
athach opened this issue Nov 12, 2020 · 1 comment
Open

ZipFile.Save() unhandled exception #10

athach opened this issue Nov 12, 2020 · 1 comment

Comments

@athach
Copy link

athach commented Nov 12, 2020

Hi,
First of, thank you very much for your sharing this excellent library!

There is an unhandled exception in SharedUtilities.GetFileLength() when calling ZipFile.Save() and it contains a file that you dont have access to.

I dont know how you want it to work but maybe this exception should be caught, a ZipError event is triggered and the save operation continuous without the file?

Maybe the current way of determining file size was chosen for a reason but there is an alternate way:
return new FileInfo(fileName).Length;

Best regards

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 Ionic.Zip.SharedUtilities.GetFileLength(String fileName) in DotNetZip-master\Zip\Shared.cs:line 54
at Ionic.Zip.ZipEntry.MaybeUnsetCompressionMethodForWriting(Int32 cycle) in DotNetZip-master\Zip\ZipEntry.Write.cs:line 741
at Ionic.Zip.ZipEntry.WriteHeader(Stream s, Int32 cycle) in Zip\ZipEntry.Write.cs:line 1026
at Ionic.Zip.ZipEntry.Write(Stream s) in DotNetZip-master\Zip\ZipEntry.Write.cs:line 2214
at Ionic.Zip.ZipFile.Save() in DotNetZip-master\Zip\ZipFile.Save.cs:line 169

@athach athach changed the title ZipFeil.Save() unhandled exception ZipFile.Save() unhandled exception Nov 12, 2020
@athach
Copy link
Author

athach commented Nov 13, 2020

A little background information. I am using the library in a backup application. Some files scheduled for backup may locked by another application, in this case the backup should still be completed but without the files that cannot be accessed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant