如何从.net服务器中下载文件? [英] How to download a file from server in .net?

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

问题描述

如何从.net服务器中下载文件?
谢谢.
DK Dixit

How to download a file from server in .net?
Thanks.
DK Dixit

推荐答案

使用以下代码

use following code

System.String filename = "myFile.txt";

// set the http content type to "APPLICATION/OCTET-STREAM
Response.ContentType = "APPLICATION/OCTET-STREAM";
   
// initialize the http content-disposition header to
Response.AppendHeader("Content-Disposition", filename);

 // transfer the file byte-by-byte to the response object
System.IO.FileInfo fileToDownload = new System.IO.FileInfo("C:\\myFile.txt");
Response.Flush();
Response.WriteFile(fileToDownload.FullName);}


请参阅CP文章
文件下载
See CP article
File Download


引用此链接:

http://shawpnendu.blogspot.com/2009/05/how-to-download-file-from-server-using.html [
Refer this link:

http://shawpnendu.blogspot.com/2009/05/how-to-download-file-from-server-using.html[^]


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

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