在asp.net中下载文件 [英] download a file in asp.net

查看:83
本文介绍了在asp.net中下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在asp.net中下载文件?

how to download a file in asp.net ?

推荐答案

^ ]


Google结果 [ http://www.venkateswarlu.co.in/articles/DotNet/Download_File.aspx [ ^ ]
http://www.etechplanet.com/blog/downloading-file-using- aspnet-and-c.aspx [ ^ ]
Google result[^]: About 243,000,000 results (0.23 seconds)

Top 2:
http://www.venkateswarlu.co.in/articles/DotNet/Download_File.aspx[^]
http://www.etechplanet.com/blog/downloading-file-using-aspnet-and-c.aspx[^]


使用此功能可在asp.net中下载文件
use this function to download files in asp.net
private void LoadFile(string sFilename, string strpath,string ApplicationType)
{
byte[] bt = null;

 bt = File.ReadAllBytes(strpath);

Response.Clear();
        Response.ContentType ="ApplicationType"; //"application/pdf","application/Word" etc.
        Response.AddHeader("Content-Disposition", "attachment; filename=\"" + sFilename + "\"");
        Response.Flush();


MemoryStream ms = new MemoryStream();
        ms.Write(databyte, 0, databyte.Length);
        ms.Position = 0;
        ms.Capacity = (int)ms.Length;
        byte[] arrbyte = ms.GetBuffer();
        ms.Close();
        Response.BinaryWrite(arrbyte);
        Response.End();
}


我认为它将解决您的问题


i think it will solve your problem


这篇关于在asp.net中下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆