Overwrite contents of ZipArchiveEntry
问题 How can I overwrite contents of a ZipArchiveEntry ? Following code using StreamWriter with StringBuilder fails if the new file contents are shorter than the original ones, for example: using System.IO.Compression; //... using (var archive = ZipFile.Open("Test.zip", ZipArchiveMode.Update)) { StringBuilder document; var entry = archive.GetEntry("foo.txt");//entry contents "foobar123" using (StreamReader reader = new StreamReader(entry.Open())) { document = new StringBuilder(reader.ReadToEnd());