<span style="font-size:14px;">//下载远程的文件
protected void lbtnDownload_Click(object sender, EventArgs e)
{
string path = ViewState["path"].ToString();
string result = string.Empty;
WebClient wc = new WebClient();
wc.BaseAddress = path;
byte[] bytes;
bytes = wc.DownloadData(wc.BaseAddress);
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", HttpUtility.UrlEncode(ViewState["name"].ToString(), System.Text.Encoding.UTF8)));
MemoryStream ms = new MemoryStream(bytes);
ms.WriteTo(Response.OutputStream);
ms.Dispose();
ms.Close();
Response.End();
}</span>
C#下载远程的文件
最新推荐文章于 2021-05-29 16:50:00 发布