0

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! :)

Jehof
  • 34,674
  • 10
  • 123
  • 155

1 Answers1

1

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.

Coda
  • 387
  • 2
  • 9
  • This is correct: the overload lets you set a new "filepath/filename" while loading the original filepath/name...@Coda is just faster at typing than I am! – BlueChippy Feb 05 '13 at 09:19