首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

在cs有一个http的rar包,怎么弹出上载提示

2012-12-18 
在cs有一个http的rar包,如何弹出下载提示在cs有一个http的rar包,如何弹出下载提示[最优解释]private void

在cs有一个http的rar包,如何弹出下载提示
在cs有一个http的rar包,如何弹出下载提示
[最优解释]

    private void DownLoadFile(string fName)
    {
        //文件路径
        string fPath = "~/Data/";
        string filePath = Server.MapPath(fPath + fName);
        //以字符流的形式下载文件
        FileStream fs = new FileStream(filePath, FileMode.Open);
        byte[] bytes = new byte[(int)fs.Length];
        fs.Read(bytes, 0, bytes.Length);
        fs.Close();
        Response.ContentType = "application/octet-stream";
        //通知浏览器下载文件而不是打开
        Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fName, System.Text.Encoding.UTF8));
        Response.BinaryWrite(bytes);
        Response.Flush();
        Response.End();
    }

[其他解释]
你直接给个文件路径就行了   超链接就行<a href="WebFile/文件.rar"> 文件名</a>,后台拼个字符串显示也许 
[其他解释]
用这个方法,也有异常,下载下来文件不对。Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8));
                Response.WriteFile(filepath);


                Response.Flush();
[其他解释]
直接访问那个rar包就行了
[其他解释]
引用:
C# code?1234567891011121314151617    private void DownLoadFile(string fName)    {        //文件路径        string fPath = "~/Data/";        string filePath = Server.MapPath(fPath + fName);   ……

这个容易引起内存溢出
[其他解释]
引用:
引用:C# code?1234567891011121314151617    private void DownLoadFile(string fName)    {        //文件路径        string fPath = "~/Data/";        string filePath = Server.Ma……

解决方法呢??
[其他解释]
引用:
引用:引用:C# code?1234567891011121314151617    private void DownLoadFile(string fName)    {        //文件路径        string fPath = "~/Data/";        string file……


不知道,所以才来求助高手的。
[其他解释]
引用:
引用:引用:引用:C# code?1234567891011121314151617    private void DownLoadFile(string fName)    {        //文件路径        string fPath = "~/Da……

那就坐等高手吧、、、
[其他解释]
在cs中如何处理,不是在html页面。

引用:
你直接给个文件路径就行了   超链接就行<a href="WebFile/文件.rar"> 文件名</a>,后台拼个字符串显示也许

[其他解释]
关注这个话题。
[其他解释]
该回复于2012-11-20 16:56:10被管理员删除
[其他解释]
关注这个话题。 
[其他解释]
引用:
用这个方法,也有异常,下载下来文件不对。Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8));
                Response.Wr……


要说明白“怎么个不对”法,也就是可重现性。

如果你说path写成"c:"于是不对了,那么谁会管这种没有技术含量的事情呢?!
[其他解释]
RAR文件就好办了,直接一个A标签链接到就可以了,因为是文件,会直接提示下载

热点排行