Zipping of excel files using c#

Posted by Amritha444 under C# on 6/24/2020 | Points: 10 | Views : 2967 | Status : [Member] | Replies : 1

Im trying to zip some excel and xml files using c# using dll

ZipFile zip = new ZipFile();
zip.AlternateEncodingUsage = ZipOption.AsNecessary;
foreach (string filepath in folderPaths)
zip.AddFile(filepath, "Files");

string zipName = String.Format("Zip_{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
zip.Save(Path.Combine(folderPath, zipName));
foreach (string filepath in folderPaths)
if ((System.IO.File.Exists(Path.Combine(filepath))))

above code works well but issue is a directory name files inside zip folder i want to remove this

when i remove zip.AddDirectoryByName("Files"); this code a folder with folderPath creatind instead of files .How to remove this .How files directly coming under zip folder


Posted by: Ishan7 on: 11/26/2020 [Member] Starter | Points: 25

Single step extraction of existing zip libraries
ZipFile.ExtractToDirectory(@”D:\”, @”D:\dotnetcurry\”);

Single step compression of entire folder
ZipFile.CreateFromDirectory(@”D:\devcurry”, @”D:\”);

For more information follow this link

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response