为什么循环只进行了一次

tianfu1 tianfu1 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我先获得了所要下载文件的文件名,将他们保存到一个数组中。
然后遍历数组中的文件进行下载
但是循环只进行了一次便结束了
请各位看看是怎么回事,我调试的时候数组的长度是4,很奇怪

代码如下

protected void DownLoad(object sender, EventArgs e)
{
String[] fileList = FileNames.Value.Split(':');///获取选中的文件的相对路径数组

foreach (String fileName in fileList)
FileDownLoad(Response, Request.MapPath(fileName));

}


private void FileDownLoad(HttpResponse response, String fullFileName)
{
FileInfo downLoadFile = new FileInfo(fullFileName);

response.Clear();
response.ClearHeaders();
response.Buffer = false;
response.ContentType = "application/octet-stream";
response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(downLoadFile.FullName, System.Text.Encoding.ASCII));
response.AppendHeader("Content-Length", downLoadFile.Length.ToString());
response.WriteFile(downLoadFile.FullName);
response.Flush();
response.End();
}
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
tianfu1
.NET社区 62,274 成员 668,968 内容