I work on c# app doing compress to file using ziparchieve
my dot net version 4.7
- CreateZipFile(string fileName, out List
files, extension type xlsx)
I need to pass extension type as optional parameter and if no extension type passed then select all files on folder
if extension type as xlsx passed then compress files that have extension xlsx only
also I need list of string files as out because may be I used again
- public static void CreateZipFile(string fileName, List
files) - {
- using (ZipArchive zip = ZipFile.Open(fileName, ZipArchiveMode.Update))
- {
- foreach (var file in files)
- {
- if (!zip.Entries.Any(zipFile => file.Contains(zipFile.FullName)))
- {
- zip.CreateEntryFromFile(file, Path.GetFileName(file), CompressionLevel.Optimal);
- }
- }
- }
- }
Replies
Know the answer? Post it — somebody with the same question will find it here.