2011-08-22 7 views
3

Wehen zip.MaxOutputSegmentSize를 충분히 높게 설정하면 zip 파일이 하나만 작동합니다. 최대한 빨리 분할 파일 중 하나가 최대 크기에 도달하면 MaxOutputSegmentSize를 제한합니다. 20MB와 같은 값이 있으면 파일 ".z02"의 끝에 알 수 있습니다. 값이 더 작 으면 또한 나중에 일부 파일이 발생합니다.DotNetZip 라이브러리 : split 아카이브 생성 - System.UnauthorizedAccessException

내가 zip.ZipErrorAction = ZipErrorAction.Skip을 사용하거나 .Retry를 사용하면 대신 System.ObjectDisposedException이 발생합니다.

여기의 문제 또는 DotNetZip 라이브러리의 버그입니까?

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 

는 스택 트레이스 : ZipErrorAction.Skip 사용

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) 

예외 및 스택 트레이스 (이 경우 3 분할에서 :

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() 
... 

프로세스는 대상 폴더에 필터 모니터는 의심스러운 아무것도 표시되지 않습니다 파일이 생성되면 예외가 발생 함)

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 
+0

분할 된 아카이브와 관련된 DotNetZip의 v1.9.1.5에 버그가있었습니다. 어떤 버전을 사용하고 있습니까? – Cheeso

+0

최신 1.9.1.8 "DotNetZip v1.9 용 개발자 키트 패키지이며,이 패키지는 Sat-08-06-2011-215945.06으로 포장되었습니다." – SunDawn

+0

unauthorizedaccessexception은 File.Move 메서드와 관련이 있으며 파일이 이미 존재하고 이미 사용 중이거나 (자신의 응용 프로그램을 사용하고있을 수도 있음) 읽기 전용이거나 권한이없는 것일 수 있습니다. 그렇지 않으면 만들 권한이 없습니다. 또는 해당 디렉토리의 파일을 삭제하십시오. DotNetZip 커뮤니티가 도움이 될 수 있다고 생각하거나 또는 SysInternals Suite 도구를 사용하여 해당 폴더의 파일 작업을보고 디버깅하는 동안 진행되는 작업을 볼 수 있습니다. objectdisposedexception에 대한 스택 추적 (stacktrace)은 우리에게 무언가를 알려주고 게시 할 수도 있습니다. – mtijn

답변

1

문제는 한 폴더에 gzip 파일 (.gz 암호 포함)이 있다는 것입니다. DotNetZip에서 분할 할 수없는 것 같습니다 (7zip 수 없습니다). 따라서 gzip 파일로 채워진 .zip 파일의 끝에 도달하면 예외가 발생합니다.

필자는 이제 모든 해결 방법을 사용하여 전체 크기를 계산하고 최대 크기에 도달 할 때마다 단일 (분할되지 않은) zip 파일을 만듭니다.

DotNetZip의 문제점 (버그?)이 남아 있습니다.