AddDirectory

Mar 20, 2010 at 1:05 PM

i would like a zip folder including subfolders determined....

 

example: Folder1/Folder2/Folder3

 

 
private void button1_Click(object sender, EventArgs e)
        {
           this.Save(); //Make Folder/SubFolder & SaveFileDialog


           using (ZipFile zip = new ZipFile(this.sD.FileName)) // SaveFileDialog name
            {
             
                zip.AddDirectory(Application.StartupPath + (@"\Folder1\Folder2\Folder3"));
                
                zip.Save();
                Directory.Delete(Application.StartupPath + @"\Folder1", true);
                
            }


        }


ok, zip is created...

i open the zip, i see this path...

Test.zip\Dokumente und Einstellungen\Joe\Eigene Dateien\Visual Studio 2008\Projects\Test\Test\bin\Debug\Folder1\Folder2\Folder3

it is this path but it is possible

 

Test.zip\Folder1\Folder2\Folder3

what am i doing wrong?
Coordinator
Mar 23, 2010 at 5:55 PM

Try something like this:

private void button1_Click(object sender, EventArgs e)
{
    this.Save(); //Make Folder/SubFolder & SaveFileDialog

    using (ZipFile zip = new ZipFile(this.sD.FileName)) // SaveFileDialog name
    {

        string pathToZip = Application.StartupPath + @"\Folder1\Folder2\Folder3";
        string pathToUseInArchive = @"\Folder1\Folder2\Folder3";
        zip.AddDirectory(pathToZip, pathToUseInArchive);
        zip.Save();
        Directory.Delete(Application.StartupPath + @"\Folder1", true);

    }
}

Also, check the documentation..