开发者

DotNetZip Library: creating split Archive - System.UnauthorizedAccessException

Wehen i set the zip.MaxOutputSegmentSize high enough so there would be only one zip file it works. As soon as i limit the MaxOutputSegmentSize i get this error after one of the split files reaches its max size - when i have a value like 20MB it allways occcurs on the end of file ".z02", if the value is smaller it may also occur some file later.

If i use zip.ZipErrorAction = ZipErrorAction.Skip or .Retry i get an System.ObjectDisposedException instead.

What might be the Problem here or is this a Bug in DotNetZip Library?

ZipFile zip = new ZipFile(backupPath + "Backup.zip");
            zip.MaxOutputSegmentSize = maxSize;
            //zip.TempFileFolder = @"D:\Backup\Temp"; //seems not to make any difference

            zip.Comment = "Backup created at " + System.DateTime.Now.ToString("G");
            zip.AddFile(dbBackup.FullName,"Database");
            zip.AddDirectory(physicalAppPath,"Application");

           zip.AddDirectory(mailArchivePath,"MailArchive");
           zip.Save(); //Exception occurs here

StackTrace:

bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
bei System.IO.File.Move(String sourceFileName, String destFileName)
bei Ionic.Zip.ZipSegmentedStream.TruncateBackward(UInt32 diskNumber, Int64 offset)
bei Ionic.Zip.ZipEntry.Write(Stream s)
bei Ionic.Zip.ZipFile.Save()
bei MyProject.Configuration.Backup.BackupLogic.Backup(Boolean monthly) in D:\projects\MyProject.Configuration\Backup\BackupLogic.cs:Zeile 100.
bei MyProject.Configuration.Backup.BackupLogic.ScheduledBackup() in D:\projects\MyProject.Configuration\Backup\BackupLogic.cs:Zeile 42.
bei MyProject.Configuration.BackupTimer.CreateThread(Object parameters) in D:\projects\MyProject.Configuration\BackupTimer.cs:Zeile 60.
bei System.Threading.ExecutionContext.runTryCode(Object userData)
bei Sy开发者_开发技巧stem.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart(Object obj)

Exception and StackTrace for using ZipErrorAction.Skip:

ObjectDisposed Exception was unhandled: Auf eine geschlossene Datei kann nicht zugegriffen werden. (Could not access an closed file)

bei System.IO.FileStream.get_Position()
bei Ionic.Zip.ZipEntry.Write(Stream s)
bei Ionic.Zip.ZipFile.Save()
...

Process Monitor with filter on the Destination Folder shows nothing suspicious: (in this case 3 split files were created, then the exception occured)

12:35:25.6312905 PM w3wp.exe    5380    CreateFile  D:\Backup   SUCCESS Desired Access: Write Data/Add File, Synchronize, Disposition: Open, Options: , Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a, Impersonating: NT-AUTORITÄT\IUSR, OpenResult: Opened
12:35:25.6319249 PM w3wp.exe    5380    CloseFile   D:\Backup   SUCCESS 
12:35:27.7507327 PM w3wp.exe    5380    CreateFile  D:\Backup   SUCCESS Desired Access: Write Data/Add File, Synchronize, Disposition: Open, Options: , Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a, Impersonating: NT-AUTORITÄT\IUSR, OpenResult: Opened
12:35:27.7511904 PM w3wp.exe    5380    CloseFile   D:\Backup   SUCCESS 
12:35:32.9936509 PM w3wp.exe    5380    CreateFile  D:\Backup   SUCCESS Desired Access: Write Data/Add File, Synchronize, Disposition: Open, Options: , Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a, Impersonating: NT-AUTORITÄT\IUSR, OpenResult: Opened
12:35:32.9941529 PM w3wp.exe    5380    CloseFile   D:\Backup   SUCCESS 


The Problem was that there are gzip files (.gz with password) in one Folder - it seems that DotNetZip can not split those (7zip can). So as soon as it reaches the end of a .zip file filled with those gzip files the exception occurs.

I used now a workaround so i cycle all my files, calc the total size and create single (not splitted) zip files each time i reach my max size.

The Problem (Bug?) for DotNetZip remains.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜