title: DotNetZip Library: creating split Archive - System.UnauthorizedAccessException
body: <p>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.</p>
  
  <p>If i use zip.ZipErrorAction = ZipErrorAction.Skip or .Retry i get an System.ObjectDisposedException instead.</p>
  
  <p>What might be the Problem here or is this a Bug in DotNetZip Library?</p>
  
  <pre><code>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
  </code></pre>
  
  <p>StackTrace:</p>
  
  <pre><code>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 System.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)
  </code></pre>
  
  <p>Exception and StackTrace for using ZipErrorAction.Skip:</p>
  
  <pre><code>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()
  ...
  </code></pre>
  
  <p>Process Monitor with filter on the Destination Folder shows nothing suspicious: (in this case 3 split files were created, then the exception occured)</p>
  
  <pre><code>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 
  </code></pre>