Zipping File

Here is the function for zipping the Files...


//Function for Zipping the Folder
private void Zipper()
{
try
{
//Launch the zip.exe console app to do the actual zipping
System.Diagnostics.ProcessStartInfo i = new System.Diagnostics.ProcessStartInfo(AppDomain.CurrentDomain.BaseDirectory + "zip.exe");
i.CreateNoWindow = true;
string args = "";
string dest;
string strSource;

strSource = Application.StartupPath + "\\New";
if (strSource.IndexOf(" ") != -1)
{
//we got a space in the path so wrap it in double qoutes
args += "\"" + strSource + "\"";
}
else
{
args += strSource;
}

strFileName = strXmlFileName.Substring(strXmlFileName.LastIndexOf("\\") + 1);
strRootFolderName = strXmlFileName.Replace(strFileName, "");
dest = strRootFolderName;
if (dest.EndsWith(@"\") == false)
{
dest += @"\";
}



dest += strZipNo + ".zip";

if(dest.IndexOf(" ") != -1)
{
//we got a space in the path so wrap it in double qoutes
args += " " + "\"" + dest + "\"";
}
else
{
args += " " + dest;
}

i.Arguments = args;


//Checking For Already Exist
FileInfo finfoZip = new FileInfo(dest);
if (finfoZip.Exists)
{
finfoZip.Delete();
}



//*************** New Zip Function
ZipNew(strSource, dest);
blnZip = true;

//Deleting the Temp Directory
DeleteXMLFile(1);
}
catch (Exception ex)
{
MessageBox.Show("Error while Ziping" + strFileName + "file." + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
toolStripProgressBar1.Maximum = 0;
blnZip = false;
}
}


Regards
Anil Pandey


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: