色尼玛亚洲综合影院,亚洲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下載文件的代碼,轉載需保留來源!

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

主站蜘蛛池模板: 济宁市| 贵溪市| 平陆县| 孝昌县| 舟山市| 珲春市| 乐安县| 苍山县| 鸡东县| 塔河县| 蓝田县| 富锦市| 巴东县| 松阳县| 庄浪县| 壤塘县| 正镶白旗| 江口县| 大荔县| 明光市| 淳安县| 兴仁县| 安多县| 万山特区| 宝应县| 万荣县| 哈巴河县| 杨浦区| 淮安市| 福鼎市| 东乡族自治县| 济阳县| 格尔木市| 隆昌县| 稷山县| 抚松县| 多伦县| 隆回县| 松阳县| 佳木斯市| 青海省|