色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

在.NET中利用XMLHTTP下載文件的代碼

利用XMLHTTP下載文件,和以前的方法一樣,先添加引用-COM-Microsoft Xml 3.0,然后在代碼開始處寫:
using MSXML2;
下面就是主要的代碼:
private void Page_Load(object sender, System.EventArgs e){ 
string Url = "http://dotNET.ASPx.cc/Images/logoSite.gif"; 
string StringFileName = Url.Substring(Url.LastIndexOf("/") + 1); 
string StringFilePath = Request.PhysicalApplicationPath; 
if(!StringFilePath.EndsWith("/")) 
StringFilePath += "/"; 
MSXML2.XMLHTTP _xmlhttp = new MSXML2.XMLHTTPClass(); 
_xmlhttp.open("GET",Url,false,null,null); 
_xmlhttp.send(""); 
if( _xmlhttp.readyState == 4 )    { 
if(System.IO.File.Exists(StringFilePath + StringFileName)) 
System.IO.File.Delete(StringFilePath + StringFileName); 
System.IO.FileStream fs = new System.IO.FileStream(StringFilePath + StringFileName, System.IO.FileMode.CreateNew); 
System.IO.BinaryWriter w = new System.IO.BinaryWriter(fs); 
w.Write((byte[])_xmlhttp.responseBody); 
w.Close(); 
fs.Close(); 
Response.Write ("文件已經得到。<br><a href='" + Request.ApplicationPath + StringFileName +"' target='_blank'>");     
Response.Write ("查看" + StringFileName + "</a>"); 

else 
Response.Write (_xmlhttp.statusText);    Response.End();}

AspNet技術在.NET中利用XMLHTTP下載文件的代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 民和| 修文县| 城固县| 东安县| 星子县| 囊谦县| 集贤县| 阿瓦提县| 芜湖市| 长泰县| 昔阳县| 开原市| 山东| 陆丰市| 大兴区| 通城县| 凤庆县| 东丰县| 呈贡县| 南宫市| 新民市| 永福县| 大足县| 丹凤县| 调兵山市| 襄樊市| 英山县| 高碑店市| 广丰县| 诸城市| 怀安县| 芷江| 田阳县| 冀州市| 汕尾市| 凯里市| 葫芦岛市| 荆门市| 望城县| 九龙坡区| 神木县|