日期:2014-05-19  浏览次数:20471 次

客户端循环下载文件问题?
我想客户端点击某一个按钮后可以循环下载文件,每一个文件都弹出文件保存提示窗口,
代码如下:

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);
}
    }

问题:
      如此,弹出第一个窗口点击保存后便不再弹出窗口了,这是为什么?

------解决方案--------------------
帮你顶吧 不知
------解决方案--------------------
服务器端事件,所有代码都执行完客户端才有响应,所以只有最后一个写入有效
------解决方案--------------------
该做的你都做了:

DEFAULT_CONTENT_TYPE = "application/unknown ";
"Content-Disposition ", "attachment

剩下的好像就是浏览器的事了
默认记住了上次的选择吧

试试看把文件类型改称应用程序
这样因为安全性 应该不会直接打开文件