日期:2014-05-17  浏览次数:21180 次

继续发帖求教:用C#实现文件下载时,没反应,点击左下角图标显示乱码。
下载代码如下(这段代码是没问题的):

string filePath = DownFiletbl.Rows[e.NewEditIndex].Cells[9].Text;
        int intStart = filePath.LastIndexOf("\\") + 1; 
        string saveFileName = filePath.Substring(intStart, filePath.Length - intStart);
        string FileType = "text/html";
        
        Response.Clear();
        Response.Buffer = true;
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
        Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(saveFileName, Encoding.UTF8).ToString());
        Response.ContentType = FileType;

        Response.WriteFile(filePath);
        Response.Flush();
        Response.Close();
        Response.End();

运行后,下载界面没弹出,点左下角提示如下:

行:709
字符:17
错误:Sys.ArgumentException:..一串乱码

代码:0
URL:...

不知道我的页面中哪里有错造成的,第一次写网页程序,调试太麻烦了,求大侠指点,谢谢

------解决方案--------------------
参考http://ts.you1314.com/Article/ArticleDetail/27
------解决方案--------------------
点哪个左下角啊。浏览器的么?如果是浏览器的,就是你的js有问题。贴出代码来。
------解决方案--------------------
参考:http://www.cnblogs.com/zhili/archive/2013/05/11/EAP.html