您的位置:首页 > 其它

从URL下载数据到本地文件

2009-03-01 14:07 260 查看
http://localhost:3148/test2/Default7.aspx

设置
高级

请输入URL:

已经下载,请自行检查c:/www.baidu.com.html

登录



新 闻网 页贴 吧知 道MP3图 片视 频
空间 hao123 | 更多>>

把百度设为主页
企业推广 | 搜索风云榜 | 关于百度 | About Baidu
©2009 Baidu 使用百度前必读 京ICP证030173号


code:

<%@ Import Namespace="System.net" %>
<%@ Import NameSpace="System.IO" %>
<script language ="vb" runat="server">
Sub Enter_click(ByVal sender As Object, ByVal e As EventArgs)
Dim wc As New WebClient()
Dim filePath As String
filePath = "c:/" & Path.GetFileName(txtURL.Text) & ".html"
wc.DownloadFile(txtURL.Text, filePath)
message.text = "已经下载,请自行检查" & filePath
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
请输入URL:
<br />
<asp:TextBox ID="txtURL" runat="server"></asp:TextBox>
<asp:Button ID ="enter" Text ="确定" OnClick="enter_click" runat="server" />
<p></p><asp:label ID="message" runat="server"/>
</div>
</form>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: