SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Still Have Problem With Zip that cannot be deleted (in process by someone)

Last post 10-05-2008 9:36 PM by JohnReilly. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 09-16-2008 9:15 PM

    Still Have Problem With Zip that cannot be deleted (in process by someone)

    I still have struggled with the following code: It seems it looks okay to me.  Please advice.

     ICSharpCode.SharpZipLib.Zip.ZipOutputStream oZip = new ICSharpCode.SharpZipLib.Zip.ZipOutputStream(System.IO.File.Create(System.IO.Directory.GetDirectoryRoot(System.IO.Directory.GetCurrentDirectory()) + "PAGE" + this.txtPageNumber.Text.Trim() + ".ZIP"));
     oZip.SetLevel(9);

     System.IO.FileStream fs = new System.IO.FileStream(System.IO.Directory.GetDirectoryRoot(System.IO.Directory.GetCurrentDirectory()) + "TEST." + System.Drawing.Imaging.ImageFormat.Gif.ToString().ToUpper(), System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
                    byte[ buffer = new Byte[fs.Length];
                    fs.Read(buffer, 0, buffer.Length);
                   
                    ICSharpCode.SharpZipLib.Zip.ZipEntry oZipEntry = new ICSharpCode.SharpZipLib.Zip.ZipEntry("PAGE" + this.txtPageNumber.Text.Trim() + "." + System.Drawing.Imaging.ImageFormat.Gif.ToString().ToUpper());
                    oZipEntry.DateTime = System.DateTime.Now;
                    oZipEntry.Size = fs.Length;
                    fs.Close();
                    fs = null;

                    ICSharpCode.SharpZipLib.Checksums.Crc32 oCrc32 = new ICSharpCode.SharpZipLib.Checksums.Crc32();
                    oCrc32.Reset();
                    oCrc32.Update(buffer);
                    oZipEntry.Crc = oCrc32.Value;
                    oCrc32 = null;
                   
                    oZip.PutNextEntry(oZipEntry);
                    oZip.Write(buffer, 0, buffer.Length);
                    oZip.Finish();
                    oZip.Close();
                    oZip.Dispose();               
                    oZip = null;
                   
                    oZipEntry = null;
                   
                    buffer = null;

  • 10-05-2008 9:36 PM In reply to

    Re: Still Have Problem With Zip that cannot be deleted (in process by someone)

    Hi,

    It looks like streams will be closed.  You should check out the using statement to make things exception safe.  Any exception in the code will leave streams open in your code.

    I dont know what you problem will be from what I have seen, more digging required.

    hth, -jr-

Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.