Tutorial :Adding to/Delete from zip file can't find temp files



Question:

My program lets users add files to a zip file one upload at a time. The first upload creates a zip file, and subsequent uploads add to the created file. It also displays a list of all the files in the zip file, and lets users delete individual files.

I use SharpZipLib and this works perfectly on my local computer, but once I uploaded it to the server it started crashing at CommitUpdate()

The original upload that creates the zip file is fine, but adding to the zip file, or deleting from it gives:

Could not find file 'W:\MyZipFile.zip.151.tmp'.

If I leave the window alone for a while, I can delete one file or add one file before the error starts again.

My add file method:

ZipFile z = null;  if (System.IO.File.Exists(filePath + zipFilename))       z = new ZipFile(File.OpenRead(filePath + zipFilename));  else       z = ZipFile.Create(filePath + zipFilename);  z.BeginUpdate();  z.Add(filePath + filename, filename);  z.CommitUpdate();  z.Close();  


Solution:1

I figured it out. I forgot to close the ZipFile after I displayed the list of files in the zip file. That locked the zip and wouldn't let me edit until it timed out.


Solution:2

You need to make sure that whatever user the application is running as has NTFS permissions to create and modify files in the folder designated by filepath


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »