Zip file not found

Feb 1, 2012 at 9:51 AM
Hi,

I have an asp.net application with a few classes in the app_code folder, one in particular using ionic.zip namespace.

After an undefined period of time I get a problem where a zip file doesnt appear to get created even though there are no errors in the process.  It does work most of the time and a forced recompile of the web app appears to fix it.

In an attempt to get to the bottom of this I've added the error and progress event handlers without any success.  It doesnt raise an error until my zip copy method tries to move the file.

Any ideas?

 

    public static void CompressFolder(string sourcepath, string filename)
    {

        using (ZipFile zip = new ZipFile())
        {
            zip.ZipError += MyZipError;
            zip.AddProgress += AddProgressHandler;

            zip.AddDirectory(sourcepath);           
            zip.Comment = "This zip was created at " + System.DateTime.Now.ToString("G");          
            zip.Save(filename);
            //zip.Dispose();                   
        }

    }

    public static void MyZipError(object sender, ZipErrorEventArgs e)
    {
        throw new Exception("Error saving {0}..." + e.FileName + ". Exception : " + e.Exception);
    }

    private static void AddProgressHandler(object sender, AddProgressEventArgs e)
    {
            if (e.EventType == ZipProgressEventType.Adding_Completed)
                {complete = true;}       
    }