locked
File zipping larger than 600 MB RRS feed

  • Question

  • User-1003884971 posted

       

    Hi Members,

    I've a scenario, where my current version of code need to zip file larger than 600 MB and it fails. It uses the ICSharpCode.SharpZipLib.dll [v0.81.0.1407]

    Below is the code snippet, I use. I got suggestions that using StreamUtils.Copy() method in ICSharpCode.SharpZipLib.Core namespace will make the file zipping in packets.

    The ICSharpCode.SharpZipLib.Core is available in new version of ICSharpCode.SharpZipLib.dll [v.0.86.0.518] but still my zipping fails. Can you please suggest in this.

    Note: I've to use ICSharpCode.SharpZipLib.dll as my project is build on Frame 1.1.

    Please suggest.

    Note: I use the zipped file to send via mail (compress before delivery).

    protected void CompressBeforeDelivery()

     

    {

    try

    {

     

    Crc32 _crc = new

     if (File.Exists(this.__reportsWorkingFolder+@"\"+this

    .__resultFileName+".zip"))

    File.Delete(this.__reportsWorkingFolder+@"\"+this.__resultFileName+".zip");

    ZipOutputStream _zp = new ZipOutputStream(System.IO.File.Create(this.__reportsWorkingFolder+@"\"+this.__resultFileName+".zip"));

    _zp.SetLevel(6);

    FileStream _fs = File.OpenRead(this

    .__deliverThisFile);

    byte[] _buffer = new byte[_fs.Length];

    _fs.Read(_buffer, 0, _buffer.Length);

    ZipEntry _entry = new ZipEntry(new FileInfo(this

    .__deliverThisFile).Name);
    byte[] buffer = new byte[2048]; //My changes *****************

    StreamUtils.Copy(_fs, _zp, buffer); //My changes *******************

    _entry.DateTime = DateTime.Now;

    _entry.Size = _fs.Length;

    _fs.Close();

    _crc.Reset();

    _crc.Update(_buffer);

    _entry.Crc = _crc.Value;

    _zp.PutNextEntry(_entry);

    _zp.Write(_buffer, 0, _buffer.Length);

    _zp.Finish();

    _zp.Close();

    //delete the current results file and make the zip file as the results file that will be delivered.

    DeleteLocalCopyOfDeliveredFile();

    this.__deliverThisFile = this.__reportsWorkingFolder+@"\"+this

    .__resultFileName+".zip";

    }

    catch

    (Exception ex)

    {

    throw

    (ex);

     

    }

    Friday, March 18, 2011 3:18 AM

All replies

  • User-610330605 posted

    Note: I use the zipped file to send via mail (compress before delivery).

    Are you trying to zip and send a 600 MB file?

    Will the mail server accept such a huge attachment?

    Friday, March 18, 2011 9:46 AM
  • User-1003884971 posted

    I'm trying to zip a file larger than 600 MB, so it'd be in reduced size. And then trying to send the zip file vai mail.

    Friday, March 18, 2011 10:10 AM
  • User-610330605 posted

    I'm trying to zip a file larger than 600 MB, so it'd be in reduced size. And then trying to send the zip file vai mail.

    What ratio of compression are you expecting? Usually the mail servers limit attachment size to 10 - 20 MB.

    Friday, March 18, 2011 10:33 AM
  • User-1003884971 posted

    Jerry,

    I'm not concerned about the mail attachment.

    I need the current code to compress files larger than 600 MB. Once zipped I can FTP the file to my clients rather mailing them.

    Kindly suggest.

    Saturday, March 19, 2011 6:52 AM