我想客户端点击某一个按钮后可以循环下载文件,每一个文件都弹出文件保存提示窗口,
代码如下:string[] Files = new string[]{...};
for(i=0;i<Files.Length;i++)
{
string DownloadPath = FilePath+"\\"+FileName[i];
System.IO.FileInfo fileInfo=new System.IO.FileInfo(DownloadPath);
string fileextname=fileInfo.Extension;
string DEFAULT_CONTENT_TYPE = "application/unknown";
string filecontenttype;
filecontenttype=DEFAULT_CONTENT_TYPE; Response.Clear();
Response.Charset = "utf-8";
Response.Buffer= true;
EnableViewState = false;
Response.ContentEncoding = System.Text.Encoding.UTF8; Response.AppendHeader("Content-Disposition","attachment;filename=" + FileName[i]);
Response.ContentType=filecontenttype; Response.WriteFile(DownloadPath);
Response.Flush();
Response.Close(); Response.End(); if(File.Exists(DownloadPath))
{
File.Delete(DownloadPath);
}
}问题:
如此,弹出第一个窗口点击保存后便不再弹出窗口了,这是为什么?
代码如下:string[] Files = new string[]{...};
for(i=0;i<Files.Length;i++)
{
string DownloadPath = FilePath+"\\"+FileName[i];
System.IO.FileInfo fileInfo=new System.IO.FileInfo(DownloadPath);
string fileextname=fileInfo.Extension;
string DEFAULT_CONTENT_TYPE = "application/unknown";
string filecontenttype;
filecontenttype=DEFAULT_CONTENT_TYPE; Response.Clear();
Response.Charset = "utf-8";
Response.Buffer= true;
EnableViewState = false;
Response.ContentEncoding = System.Text.Encoding.UTF8; Response.AppendHeader("Content-Disposition","attachment;filename=" + FileName[i]);
Response.ContentType=filecontenttype; Response.WriteFile(DownloadPath);
Response.Flush();
Response.Close(); Response.End(); if(File.Exists(DownloadPath))
{
File.Delete(DownloadPath);
}
}问题:
如此,弹出第一个窗口点击保存后便不再弹出窗口了,这是为什么?
"Content-Disposition","attachment剩下的好像就是浏览器的事了
默认记住了上次的选择吧试试看把文件类型改称应用程序
这样因为安全性 应该不会直接打开文件