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).
protectedvoid CompressBeforeDelivery()
{
try
{
Crc32 _crc = new
if
(File.Exists(this.__reportsWorkingFolder+@"\"+this
Member
71 Points
177 Posts
File zipping larger than 600 MB
Mar 18, 2011 03:18 AM|arunveerappan|LINK
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);
}
Contributor
4812 Points
1289 Posts
Re: File zipping larger than 600 MB
Mar 18, 2011 09:46 AM|jerryjoseph|LINK
Are you trying to zip and send a 600 MB file?
Will the mail server accept such a huge attachment?
linkedin | twitter | www.jerryjoseph.net
Member
71 Points
177 Posts
Re: File zipping larger than 600 MB
Mar 18, 2011 10:10 AM|arunveerappan|LINK
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.
Contributor
4812 Points
1289 Posts
Re: File zipping larger than 600 MB
Mar 18, 2011 10:33 AM|jerryjoseph|LINK
What ratio of compression are you expecting? Usually the mail servers limit attachment size to 10 - 20 MB.
linkedin | twitter | www.jerryjoseph.net
Member
71 Points
177 Posts
Re: File zipping larger than 600 MB
Mar 19, 2011 06:52 AM|arunveerappan|LINK
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.