Using memorystream and DotNetZip in MVC gives "Cannot access a closed Stream"
Posted
by
Frode Lillerud
on Stack Overflow
See other posts from Stack Overflow
or by Frode Lillerud
Published on 2012-10-16T16:58:38Z
Indexed on
2012/10/16
17:00 UTC
Read the original article
Hit count: 415
asp.net-mvc
|dotnetzip
I'm trying to create a zipfile in a MVC method using the DotNetZip components.
Here is my code:
public FileResult DownloadImagefilesAsZip()
{
using (var memoryStream = new MemoryStream())
{
using (var zip = new ZipFile())
{
zip.AddDirectory(Server.MapPath("/Images/"));
zip.Save(memoryStream);
return File(memoryStream, "gzip", "images.zip");
}
}
}
When I run it I get a "Cannot access a closed Stream" error, and I'm not sure why.
© Stack Overflow or respective owner