views:

306

answers:

2

I'm using SharpZipLib to create a zip file of a directory in a .NET 3.5 project, and I'm creating the archive like that :

fastZip.CreateZip(Server.MapPath(zipToPath), Server.MapPath(zipFromPath), true, null);

And that doesn't set neither files nor folders filters.

The problem is that the outcome zip file only has some of the sub-directories in that directory and not all of them, say the directory I want to compress has 3 sub-directories, the resulting zip file has only one of them.

Any ideas why is this happening?

+1  A: 

A couple of possibles:

Permissions - Since you're using Server.MapPath(), I'm assuming this is a website. In a partial-trust environment the website code has very few permissions, and the library may be swallowing any permissions errors that are occurring during the zip process.

Filenames - Could be a problem with filename length, spaces in the filenames, etc, etc. Since you haven't provided any examples (of the file/directory names, there's no way to narrow it down.

HiredMind
A: 

After some debugging I've found the problem. The cause of the issue is that another process is accessing the created zip file during adding files to it, which causes the SharpZipLib process to terminate and throw an exception, leaving the created zip file with only some of the files.

For more please read my How to know which processes is using a file under ASP.NET? question.

Moayad Mardini