У меня есть несколько файлов конкретного пользователя , которые должны быть Загружены при нажатии кнопки «Загрузить все».Я могу сохранить результат из Процедура в objResult .Мне нужно загрузить несколько файлов пользователя как Zip-файл .
Ниже приведен код для одноразовой загрузки:
public ActionResult DownloadParticularFile(Int64 NurseId, Int64 PostedJobId, Int64 DocumentId)
{
NurseDAL objNurseDAL = new NurseDAL();
Result objResult = objNurseDAL.FetchDocumentURLfromDocID(DocumentId);
string path = "D:/TFSProjects/Dot Net Project/NurseOneStop.WebSite/NurseOneStop.WebSite/";
byte[] fileBytes = System.IO.File.ReadAllBytes(path + objResult.Results.DocumentUrl);
var URL = objResult.Results.DocumentUrl;
string fileName = Path.GetFileName(URL);
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
}
Этокак я использую кнопку «Загрузить все»:
public ActionResult DownloadAll(Int64 NurseId, Int64 PostedJobId)
{
NurseDAL objNurseDAL = new NurseDAL();
Result objResult = objNurseDAL.FetchDocumentListforNurse(NurseId, PostedJobId);
using (var zipStream = new ZipOutputStream(Response.OutputStream))
{
foreach(string filePath in objResult.Results)
{
string path = "D:/TFSProjects/Dot Net Project/NurseOneStop.WebSite/NurseOneStop.WebSite/";
byte[] fileBytes = System.IO.File.ReadAllBytes(path + objResult.Results.DocumentUrl);
var URL = objResult.Results.DocumentUrl;
string fileName = Path.GetFileName(URL);
zipStream.PutNextEntry(fileName);
zipStream.Write(fileBytes, 0, fileBytes.Length);
}
zipStream.Flush();
zipStream.Close();
}
return null;
}
Мне нужно загрузить файлы в формате Zip.
PS Понятия не имею, как работать с Zip.