c# - Trying Zip different folders in in a specified directory using ZipFile -
i found code below on stack overflow tried didn't know how use fully.
basically want able zip files separately using foreach loop won't have list of files change each time.
so how can list of folders/directories inside root directory array?
public static void createzipfile(string filename, ienumerable<string> files) { var zip = zipfile.open(filename, ziparchivemode.create); foreach (var file in files) { zip.createentryfromfile(file, path.getfilename(file), compressionlevel.optimal); } zip.dispose(); }
normally use dotnetzip
, code:
using (var file = new zipfile(zipname)) { file.addfiles(filenames, directorypathinarchive); file.save(); }
where zipname
name of zip archive want create , filenames
names of files want put in it.
Comments
Post a Comment