xml| downloads use XMLHTTP to download files, as in previous methods, add references-com-microsoft Xml 3.0, and 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 = "20061130113617553.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 ("The file has been obtained.) <br><a href= ' "+ Request.applicationpath + stringfilename +" ' target= ' _blank ' > ");
Response.Write ("View" + Stringfilename + "</a>");
}
Else
Response.Write (_xmlhttp.statustext);
Response.End ();
}