こんにちは、私はZipのダウンロードに必要なdllファイルをダウンロードしました。私は正常にサーバーディレクトリに複数のpdfファイルをダウンロードして、私はzip thos複数のファイルのコードを書いてクライアントにダウンロードptionを提供しますが、n個のpdfファイルから最後のn個の番号ファイルがパスの下にありません C:プログラムファイル(x86)\ Common Files \ microsoft shared \ DevServer \ 11.0 このファイルは見つかりませんでした。 zip.Save(Response.OutputStream) - コード行にスローされました。どんなタイプの助けもありがとう。Zip.Save(Response.OutputStream)Error
protected void Btn_DownloadZip_Click(object sender, System.EventArgs e)
{
try
{
string[] filePaths = Directory.GetFiles(Server.MapPath("~/EStatement/"));
List<ListItem> files = new List<ListItem>();
foreach (string filePath in filePaths)
{
files.Add(new ListItem(Path.GetFileName(filePath), filePath));
}//Collecting names of file from specified Path
using (ZipFile zip = new ZipFile())
{
zip.AlternateEncodingUsage = ZipOption.AsNecessary;
zip.AddDirectoryByName("Zip_Statements");
for(int i=0;i<files.Count;i++)
{
string FPtoAdd = files[i].Text;
zip.AddFile(FPtoAdd, "Zip_Statements");
}
Response.Clear();
Response.BufferOutput = false;
string ZipName = string.Format("Zip_{0}", DateTime.Now.ToString("yyyy-MM-dd-HHmmss"));
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "attachment; filename=" + ZipName);
zip.Save(Response.OutputStream); //ERROR LINE
Response.End();
}
}
catch (Exception Ex)
{
ExceptionLogging.SendErrorToText(Ex);
}
}