I'm developing an ASP.NET MVC 5 app with .NET Framework 4.5.1 and C#.
I have an action method that must return one or more xml. These XML files will be in memory, I will generate each XML for an Entity Framework data model. At the end I will have this var: List<XmlDocument> docs;
And not sure if I can return multiple files in an Action method. To return only one, I've thought that I could return a zip with all of them.
Reading the MSDN documentation I see that I can do this:
XmlDocument xmlDoc = new XmlDocument( );
MemoryStream xmlStream = new MemoryStream( );
xmlDoc.Save( xmlStream );
GZipStream zip = new GZipStream(xmlStream, CompressionLevel.Fastest);
But, how can I add more than one file to a GZipStream
? And, what do I have to do to set a name for each doc in GZipStream
?
I'm sorry but this is the first time I do this and I'm searching how to do it, but I haven't found how to add multiples MemoryStream
in a GZipStream.