您现在的位置是:首页 >

ios 下载文件 在.NET中利用XMLHTTP下载文件

火烧 2021-07-04 01:26:11 1065
在.NET中利用XMLHTTP下载文件 利用XMLHTTP下载文件 和以前的方法一样 先添加引用--Micro oft Xml 然后在代码开始处写 u i g MSXML 下面就是主要的代码 riva
ios 下载文件 在.NET中利用XMLHTTP下载文件

在.NET中利用XMLHTTP下载文件  

     利用XMLHTTP下载文件 和以前的方法一样 先添加引用--Microsoft Xml 然后在代码开始处写      using MSXML ;   下面就是主要的代码      private void Page_Load(object sender System EventArgs e)   {    string Url = _ / / gif ;    string StringFileName = Url Substring(Url LastIndexOf( / ) + );    string StringFilePath = Request PhysicalApplicationPath;    if(!StringFilePath EndsWith( / )) StringFilePath += / ;    MSXML XMLHTTP _xml();    _xml open( GET Url false null null);    _xml send( );    if( _xml readyState == )    {    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[])_xml responseBody);    w Close();    fs Close();    Response Write ( 文件已经得到 <br><a + Request ApplicationPath + StringFileName + target= _blank > );    Response Write ( 查看 + StringFileName + </a> );    }    else    Response Write (_xml statusText);    Response End();   } lishixinzhi/Article/program/net/201311/12150  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码