public FileResult batchDownload(string runids) { List <string> filepaths = new List <string>(); foreach (string runid in runids.Split(",")) { filepaths.Add(_context.getRawPath(Convert.ToInt32(runid.Split("-")[1])).Replace("json", "txt")); } //filepaths.Add(@"C:\Users\griff\Downloads\RUN_20191223_164427_CP53.json"); using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile()) { zip.AlternateEncodingUsage = ZipOption.AsNecessary; zip.AddDirectoryByName("runs"); foreach (string filepath in filepaths) { zip.AddFile(filepath, "runs"); } string zipName = String.Format("RawArchive_{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss")); using (MemoryStream memoryStream = new MemoryStream()) { zip.Save(memoryStream); return(File(memoryStream.ToArray(), "application/zip", zipName)); } } }