Frage

I am not sure if its a gap in my understanding. I have to zip a folder which sits on a server in the same network. Suppose I have a folder WebSite on the D drive of ABC machine on XYZ domain (same network as my machine). I use the following code to zip it

        using (ZipFile myZip = new ZipFile())
        {
            myZip.AddSelectedFiles("*.*", @"\\ABC.XYZ.com\d$\WebSite\", true);

            myZip.Save(@"\\ABC.XYZ.com\d$\Test.zip");
        }

Using this code I get an archive in the D drive of the server ABC but, the structure of the zip would look like this.

Test.zip -> ABC.XYZ.com -> d$ -> Website

Is there some alternative way to get the Zip file like Test.zip -> Website, while on a network path.

War es hilfreich?

Lösung

Use the ZipFile.AddDirectory method:

using (ZipFile myZip = new ZipFile())
{
    myZip.AddDirectory(@"\\ABC.XYZ.com\d$\WebSite\", "WebSite");
    myZip.Save(@"\\ABC.XYZ.com\d$\Test.zip");
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top