나는 다운로드에 대한 사용자의 브라우저로 스트리밍 한 후 사용자의 세션에서 파일 목록을 압축하는 데 사용하고있어이 기능을 가지고 :"잘못된 폴더"오류 SharpZipLib
public static void DownloadAllPhotos()
{
HttpContext.Current.Response.AddHeader(
"Content-Disposition", "attachment; filename=Photos.zip");
HttpContext.Current.Response.ContentType = "application/zip";
List<string> photos= new List<string>();
if (HttpContext.Current.Session != null &&
HttpContext.Current.Session["userPhotos"] != null)
{
photos = (List<string>)HttpContext.Current.Session["userPhotos"];
}
using (var zipStream = new
ZipOutputStream(HttpContext.Current.Response.OutputStream))
{
foreach (string photoUrl in photos)
{
byte[] fileBytes = File.ReadAllBytes(photoUrl);
var fileEntry = new ZipEntry(
Path.GetFileName(photoUrl))
{
Size = fileBytes.Length
};
zipStream.PutNextEntry(fileEntry);
zipStream.Write(fileBytes, 0, fileBytes.Length);
}
zipStream.Flush();
zipStream.Close();
// reset session
HttpContext.Current.Session["userPhotos"] = new List<string>();
}
}
사용자가 세션에서 사진 URL을 가지고 있고 버튼을 클릭하여이 기능을 호출하면 파일이 압축되고 사용자 브라우저에서 다운로드가 시작됩니다.
하지만 압축 된 파일을 열려고하면이 오류 얻을 :
Windows cannot open the folder.
The compressed folder "{Path to my file}" is invalid.
나는이 오류의 원인이 뭔가 잘못하고 오전?
다운로드 한 zip 파일의 디스크 크기는 얼마입니까? – cfeduke