Today I faced an issue with ASP.Net MVC, I have to download multiple files as a compressed (zip) file. Initially I thought of using third party component like DotNetZip. Later I used ZipArchive class, which comes with .Net Framework 4.5.
And here is the controller action.
In this implementation I creating text file on the fly and I am reading and using existing files as well.
Note: Following namespaces are required.
You may need to add reference of System.IO.Compression.FileSystem namespace explicitly, without this assembly reference visual studio will not recognize ZipArchive class.
Happy Coding :)
Did you like this article? Share it with your friends