public ActionResult CreateArchivePackage(GetObjectResponse response)
{
using (var memoryStream = new MemoryStream())
{
response?.ResponseStream.CopyTo(memoryStream);
using (System.IO.Compression.ZipArchive zip = new System.IO.Compression.ZipArchive(memoryStream, System.IO.Compression.ZipArchiveMode.Create, true))
{
ZipArchiveEntry zipItem = zip.CreateEntry("Asmosis" + ".xml");
using (MemoryStream originalFileMemoryStream = new MemoryStream(Encoding.Default.GetBytes(CreateXMLDocForNow().OuterXml)))
{
using (System.IO.Stream entryStream = zipItem.Open())
{
originalFileMemoryStream.CopyTo(entryStream);
return File(originalFileMemoryStream.ToArray(), "random/zip");
}
}
}
}
}
I have tried several different approaches such as converting the xml file into a stream and then adding that to the current memory stream with no luck! Any help would be greatly appreciated, this is my first time working with the streams, files, etc.