最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
利用XMLHTTP下载文件
时间:2008-01-12 编辑:简简单单 来源:一聚教程网
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 ("文件已经得到。
");
Response.Write ("查看" + StringFileName + "");
}
else
Response.Write (_xmlhttp.statusText);
Response.End();
}
-
下一个: 全面防御asp网站防黑客攻击[我的原创]
相关文章
- Python创建xml文件示例 07-17
- xml文件是什么 xml文件怎么打开 03-30
- java创建XML文件 04-28
- 对b/s结构如何部署你的xml文件~~~ 01-12
- XML 文件中出现 & ? ? 01-12
- XmlTextWriter创建XML文件 01-12