Quantcast
Channel: sharpcompress Discussions Rss Feed
Viewing all articles
Browse latest Browse all 239

New Post: SaveTo cannot call many time if there an entry added from memorystream.

$
0
0
Here is example
using (var arc = ZipArchive.Create())
{
    string str = "test.txt";
    var source = new MemoryStream(Encoding.UTF8.GetBytes(str));
    arc.AddEntry("test.txt", source, true, source.Length, null);
    arc.SaveTo(@"D:\a.zip", new CompressionInfo());
    arc.SaveTo(@"D:\b.zip", new CompressionInfo());
 }
test.txt in b.zip will be empty.

I think reset them only affect new files.
Old files always reset each time I call OpenEntryStream (or create a new stream? I didn't view so much code).
test code
var entry = arc.Entries.where(v => v.FilePath == "exist.txt");
Console.WriteLine(new StreamReader(entry.OpenEntryStream()).ReadToEnd());
Console.WriteLine(new StreamReader(entry.OpenEntryStream()).ReadToEnd());
Console.WriteLine(new StreamReader(entry.OpenEntryStream()).ReadToEnd());
if file is exist before open, the output of second and third time are same as first time.
if new added, second and third time will output empty string.

Viewing all articles
Browse latest Browse all 239

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>