色尼玛亚洲综合影院,亚洲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 ("文件已經(jīng)得到。<br><a href='" + Request.ApplicationPath + StringFileName +"' target='_blank'>");     
Response.Write ("查看" + StringFileName + "</a>"); 

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

AspNet技術(shù)在.NET中利用XMLHTTP下載文件的代碼,轉(zhuǎn)載需保留來源!

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

主站蜘蛛池模板: 钟山县| 桦甸市| 道真| 金门县| 大同市| 通化市| 台北县| 平定县| 习水县| 湖北省| 洛南县| 社旗县| 宁晋县| 扬中市| 太康县| 凯里市| 西充县| 临洮县| 独山县| 临洮县| 巴楚县| 无极县| 榆中县| 钟山县| 马龙县| 玉林市| 泗洪县| 南郑县| 自贡市| 宝山区| 敖汉旗| 大化| 利津县| 长沙县| 井研县| 舟曲县| 平潭县| 新巴尔虎右旗| 栖霞市| 辽宁省| 阿城市|