Return/Download Multiple Files from ASP.NET MVC FileResult Action

Updated on     Kisan Patel

Problem:

How to Return Multiple Files from ASP.NET MVC FileResult Action?
Downloading multiple files in ASP.NET

Solution:

Here, we have using DotNetZip library to accomplish this task, so add DotNetZip nuget package.

public ActionResult Download()
{
    var outputStream = new MemoryStream();

    using (var zip = new ZipFile())
    {
       zip.AddEntry("file1.txt", "content1");
       zip.AddEntry("file2.txt", "content2");
       zip.AddEntry("file3.doc", stream);
       zip.Save(outputStream);
    }

    outputStream.Position = 0;
    return File(outputStream, "application/zip", "filename.zip");
}

ASP.NET MVC C#