I try to create a zip archive with a simple demo text file as a If I run this code, the archive file is created automatically but foo.txt is not. However, if I change the Is this a To create a zip archive <(Var archive = new ziparchive (memorystream, zipArchiveMode.Create, true ) By using {var demoFile = archive.CreateEntry Before we can use it (var filestream = new filestream (@ "C: \ test test". MemoryStream.CopyTo (FileStream);}} , We need to deal with the zipper curve, which means that 'true' is to be given as zirperchmic in the third parameter so that we can reach the stream even after it is settled. < / Html> MemoryStream I am doing the following types:
(var memoryStream = new MemoryStream ()) (var archive = new ziparchive (memorystream, zipArchiveMode.Create)) {var demoFile = archive.CreateEntry ( "Foo.txt"); (Var entryStream = demoFile.Open ()) (var streamWriter = new streamer (entry stream)) {streamWriter.Write ("bar!"); } (Var filestream = New Flamestream (@ "C: \ Test Test.zip", Flamemade. Creat)) {using stream.CopyTo (fileStream); }}
MemoryStream with the file stream directly, the archive is created correctly:
using
( Var fileStream = new FileStream (@ "C: \ Temp \ test Zip", FileMode.Create)) {var archive = new ziparchive (filestream, filemode.create)) {// ...}
memorystream to
FileStream ?
(var memoryStream = new MemoryStream ()) ("foo.txt"); (Var entryStream = demoFile.Open ()) (var streamWriter = new streamer (entry stream)) {streamWriter.Write ("bar!"); }}
No comments:
Post a Comment