my controller looks like
[HttpPost]
public FileResult methodname(string files)
{
String CurrentDate = DateTime.Now.Date.ToString("dd-MM-yyyy");
string dir = filepath + "/" + CurrentDate + "/";
string[] fileList = files.Split(",");
var count = fileList.Length;
try
{
_log.LogInformation("Enter Action with user name " + HttpContext.Session.GetString("UserName"));
using (var memoryStream = new MemoryStream())
{
using (var ziparchive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
{
for (int i = 0; i < count; i++)
{
ziparchive.CreateEntryFromFile(dir + fileList[i], fileList[i]);
}
}
return File(memoryStream.ToArray(), "application/zip", "Attachments.zip");
}
}
catch (Exception ex)
{
_log.LogError(ex.StackTrace);
return null;
}
}