Reputation: 367
I want to zip a folder include 1 file and 1 sub folder (have some file in it).
zip.AddDirectory(pathNotesFile, string.Empty);
zip.AddFile(pathTempFiles + csvFileName, string.Empty);
I have use DotNetZip library, But after use these code above, the zip file which I get didn't have a sub folder.
Is there any way to create a zip file with a subfoler in it???
Upvotes: 2
Views: 121
Reputation: 67
In DotNetZip you can do it without calling .AddDirectory() method :
zip.AddFile(pathTempFiles + csvFileName, directoryPathInArchive: "Attachments");
Upvotes: 2
Reputation: 2646
I use ICSharpCode.SharpZipLib
public static void ZipPath(string zipFilePath, string sourceDir, string pattern, bool withSubdirs, string password)
{
FastZip fz = new FastZip();
if (password != null)
fz.Password = password;
fz.CreateZip(zipFilePath, sourceDir, withSubdirs, pattern);
}
hope this helps
Upvotes: 0