0

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.

VansFannel
  • 45,055
  • 107
  • 359
  • 626
  • gzipstream does not allow for multiple files. You should look into using [dotnetzip](https://dotnetzip.codeplex.com/) – spender Mar 23 '15 at 13:50

1 Answers1

0

GZipStream does not support multiple files. Use SharpZipLib to compress multiple files.

John Taylor
  • 446
  • 3
  • 8