'How to append to the existing csv inside a zip in C#
I am trying to modify the existing CSV inside the zip but the following code ends up creating a zip file containing an empty CSV file.
string zipFilePath = "testZipFile.zip"
using (ZipArchive zip = ZipFile.Open(zipFilePath, ZipArchiveMode.Update))
{
var file = new MemoryStream();
ZipArchiveEntry entry = zip.GetEntry("NewEntry.csv");
using (var outputStream = entry.Open())
{
outputStream.CopyTo(file);
}
entry.Delete();
stream2.CopyTo(file);
entry = zip.CreateEntry("NewEntry.csv", CompressionLevel.Fastest);
using (var entryStream = entry.Open())
{
file.CopyTo(entryStream);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
