; Can we do something in the method to automate the name of newly created zipfile

Jun 17, 2010 at 10:57 PM

Hi, I have been using the namespace for the zipping program. But I have seen that we have to provide the name of the .zip file in C# program everytime and if the user has to zip many files he cannot go the sourcecode and change the program line everytime so I copied the sourcepath to a variable & then sourcepath/destddir should be given as input to ";" method so the new zipfile is named with the same name and the path would remain same as the directory from which it has been taken from.

public void button2_Click(object sender, EventArgs e) {

        String sourcepath = System.IO.Path.GetFullPath(openFileDialog1.FileName);
String destdir = System.IO.Path.GetDirectoryName(openFileDialog1.FileName);
using (ZipFile zip = new ZipFile())


.Save(@"d:\todayTest2\");// Can I write this as zip.Save(sourcepath+ .zip); ??

.Text = "zipped";

I need to know the exact syntax of method and Is it possible to give a variable as input to that method for saving a zip file. Thanks!


Jun 17, 2010 at 10:59 PM

The syntax for the Zip.Save() method is shown in the documentation;

yes, you can pass a variable to that method.