How to compress only files without folders using the SharpZipLib library? (C#)
-
30-10-2019 - |
Question
I use the following code to create a zip file:
var files = Directory.GetFiles(targetPath);
var zip = ZipFile.Create(targetPath + "/myzip.zip");
zip.BeginUpdate();
foreach (var file in files) zip.Add(file, CompressionMethod.Deflated);
zip.CommitUpdate();
zip.Close();
I get the following structure of archive:
myzip.zip
- Folder1
- Folder2
- File1.txt
- File2.txt
- File3.txt
But I need:
myzip.zip
- File1.txt
- File2.txt
- File3.txt
Help please.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow