can't find file...

Mar 4, 2009 at 7:29 PM
Low priority Cheeso..
In testing zipping of a 21GB My Docs directory, the test user, deleted a file while the zip process was running. I assume after the process had already read the file. So when the process finished the zipping and tried to save the archive, it threw an error that it couldn't find the file.
What is happening behind the scenes when the temp file converts itself to the actual file?
I could be wrong on my assumptions, but it did give a can't find file error.

It's not a huge deal because I can tell them don't delete anything during processing, but I'm curious.
Thanks
Mar 4, 2009 at 8:06 PM
The more I started thinking about my post, the way I posted, it bothered me - not the right way to do it. Doesn't help you or me...so here is the better way-

I assume when the zipping starts, there is an initial process that catalogs all the files in the specified directory to zip, then it goes through the same directory creating the zip temp file. Finally, it converts that temp file into the actual zip archive. That right?

So to test, I started the zip process, let it finish its initial catalog (so-to-speak), then I delete a file before it can add it to the temp file, which ultimately results in file not found error.

Ok, now I feel better - sorry for the lame initial post.

Stack trace:
System.IO.FileNotFoundException was unhandled
  Message="Could not find file 'C:\\Users\\jeffy.SELLETHICS\\Documents\\ASA_waiver.pdf'."
  Source="mscorlib"
  FileName="C:\\Users\\jeffy.SELLETHICS\\Documents\\ASA_waiver.pdf"
  StackTrace:
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.FileInfo.get_Length()
       at Ionic.Zip.ZipEntry.FigureCompressionMethodForWriting(Int32 cycle) in C:\dinoch\dev\dotnet\zip\DotNetZip\Zip Partial DLL\ZipEntry.cs:line 2913
       at Ionic.Zip.ZipEntry.WriteHeader(Stream s, Int32 cycle) in C:\dinoch\dev\dotnet\zip\DotNetZip\Zip Partial DLL\ZipEntry.cs:line 3088
       at Ionic.Zip.ZipEntry.Write(Stream outstream) in C:\dinoch\dev\dotnet\zip\DotNetZip\Zip Partial DLL\ZipEntry.cs:line 3641
       at Ionic.Zip.ZipFile.Save() in C:\dinoch\dev\dotnet\zip\DotNetZip\Zip Partial DLL\ZipFile.cs:line 2999
       at Ionic.Zip.ZipFile.Save(String zipFileName) in C:\dinoch\dev\dotnet\zip\DotNetZip\Zip Partial DLL\ZipFile.cs:line 3170
       at SMG_Backup.MainForm.ZipSave(String SourceFolder, String DestFile) in C:\Users\jeffy.SELLETHICS\Documents\Visual Studio 2005\Projects\SMG Backup\SMG Backup\MainForm.vb:line 91
       at SMG_Backup.MainForm.btnZip_Click(Object sender, EventArgs e) in C:\Users\jeffy.SELLETHICS\Documents\Visual Studio 2005\Projects\SMG Backup\SMG Backup\MainForm.vb:line 73
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at SMG_Backup.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
       at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
       at System.Activator.CreateInstance(ActivationContext activationContext)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
Coordinator
Mar 5, 2009 at 3:12 AM

Yes - correct, the file needs to be present when the Save is happening, otherwise the Save() method will throw an exception. If you like you can Save() intermittently, and DotNetZip will write all the unwritten files to the zip file.  Then you can continue to add files, but any of the previously added files can be deleted or dumped or whatever.  If you Save() again, DotNetZip will just move the data from the prior save into the newly-saved archive, if you know what I mean.  Well that is the way it should work, but come to think of it I don't think I have a test case in the build to verify that those steps really work  !!    Anyway your understanding of the mechanics of the save is correct.