当前位置:编程学习 > C#/ASP.NET >>

关于 下载功能实现

网上很多下载功能代码,但是怎样可以下载exe文件的呢,我实现过,发现下载exe文件的时候,网页就会出现乱码,而不是显示下载提示。

请教大家了 --------------------编程问答-------------------- string fileName = "C:\\M.exe";
            FileInfo fileInfo = new FileInfo(fileName);

            Response.Clear();
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
            Response.AddHeader("Content-Length", fileInfo.Length.ToString());
            Response.AddHeader("Content-Transfer-Encoding", "binary");
            Response.ContentType = "application/exe";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
            Response.WriteFile(fileInfo.FullName);
            Response.Flush();
            Response.End(); --------------------编程问答-------------------- 去下载:

http://download.csdn.net/source/303617

引用这个组件,并实例化,然后可以:
 if (objInsusIOUtility.IsExistFile(Server.MapPath(file)))
                {
                    objInsusIOUtility.Download(Server.MapPath(file));
                }
                else
                {
                    objInsusJsUtility.JsAlert("文件已经被移除或是删除!");
                }
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,