tags:

views:

301

answers:

2

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();
A: 

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

ck
If was a permission issue, how would I be able to delete sometimes?
+1  A: 

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.