How to create zip file of a folder in c# windows application

  • Thread starter Thread starter John6272
  • Start date Start date
J

John6272

Guest
hi there, i have a folder in my project and i want to create zip file of that folder. i write the code but it doesnt work. please guide how to solve it.

private void button4_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBox2.Text))
{
MessageBox.Show("Please Select Saving Location", "Location Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string folderpath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Pictures\\";
string zippingpath = textBox2.Text;
ZipFile.CreateFromDirectory(folderpath, zippingpath);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

guide me please..

Continue reading...
 
Back
Top