The Gzip compression reduces the number of bytes sent from the server. This helps in cutting down bandwidth usage. This technique enables the server to serve multiple requests in a second with increased efficiency.

Follow the code below to use Gzip compression.

public bool ZipFiles(string strFolderName, bool blnOverwrite)
{
string strOutputFileName=strFolderName;
java.io.FileInputStream oFileStream;
this.m_oOutputFileList.Clear(); 
int len;
try
{
this.m_oFileOutputStream=new java.io.FileOutputStream(strOutputFileName);
this.m_oZipOutputStream=new java.util.zip.ZipOutputStream(this.m_oFileOutputStream);
this.m_oZipOutputStream.setLevel(9);
for(int i=0;i<this.m_oInputFileList.Count;i++)
{
oFileStream=new java.io.FileInputStream(this.m_oInputFileList[i].ToString());//,FileMode.Open,FileAccess.Read);  
this.m_oZipEntry=new java.util.zip.ZipEntry(Path.GetFileName(this.m_oInputFileList[i].ToString()));
this.m_oZipOutputStream.putNextEntry(this.m_oZipEntry);  
while((len=oFileStream.read(this.m_bytes))>0)
{
this.m_oZipOutputStream.write( this.m_bytes,0,len);
}
this.m_oZipOutputStream.closeEntry(); 
oFileStream.close();
oFileStream=null;
}
}
catch(Exception e)
{
this.Close();
throw e;
}
this.Close();
this.m_oOutputFileList.Add(strOutputFileName); 
return true;
}
                    

Copyright © 2008 VisualBuilder. All rights reserved