0
votes

I did this simple code with the latest version of the library DotNetZip, for some reason when I add a file I get all the folder structure. For example if I add: C:\one folder\two folders\File.doc Inside the zip file I will have one folder\two folders\File.doc But my expected result would be to have just the file.doc This is my code, I don't know if I am doing something wrong or what..:

//C#
public static void MethodOne(string PathInput, int LimitKb=0, bool DeleteInput=false)
{

using (ZipFile zip = new ZipFile())
{
//add file to zip
zip.AddFile(PathInput);
//save it
zip.Save(PathInput + ".zip");
}

}

Thanks! :)

1

1 Answers

0
votes

Use the overloaded, two-parameter call to AddFile where you specify the internal directory structure.

zip.AddFile(filename, String.Empty);

I think that would do what you want but I can't easily test it.