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();
}
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




