I have to create a ZipArchive and return it. I can add the Entries but when I return it, it comes empty and I don't know why.
Could you help me please?
Here is my code
public static ZipArchive CreateZip(Dictionary<string, Stream> nameAndContent)
{
using (var memoryStream = new MemoryStream())
{
using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Update, true))
{
foreach (var i in nameAndContent)
{
var file = archive.CreateEntry(i.Key);
using (var entryStream = file.Open())
using (var streamWriter = new StreamWriter(entryStream))
{
streamWriter.Write(i.Value);
}
}
return archive;
}
}
}