Use XMLHTTP to download files, like the previous method, first add to -com-microsoft XML 3.0, then write at the beginning of the code:
USING MSXML2;
Here is the main code:
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 (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 ("file has been obtained.
"); Response.write (" View " StringFileName " ");} else response.write (_Xmlhttp.status TEXT); response.end ();