Zipping of excel files using c#

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

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

ZipFile zip = new ZipFile();
zip.AlternateEncodingUsage = ZipOption.AsNecessary;
zip.AddDirectoryByName("Files");
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))))
{
System.IO.File.Delete(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




Responses

(No response found.)

Login to post response