ASPX保存远程图片到本地的两种方法的函数

2008-02-22 09:30:48来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

Function UpRemoteFileToLocal(ByVal UpType As String, ByVal RemoteUrl As String, ByVal LocalFile As String) As Boolean
Dim TmpResult As Boolean = False
Select Case UpType
Case "xmlhttp"
'With MSXML2
Dim myXmlHttp As New MSXML2.XMLHTTP40
myXmlHttp.open("GET", RemoteUrl, False)
myXmlHttp.send()
Dim FS As FileStream = New FileStream(LocalFile, FileMode.CreateNew)
Dim BW As BinaryWriter = New BinaryWriter(FS)
BW.Write(myXmlHttp.responseBody)
BW.Close()
FS.Close()
TmpResult = True
Case "webclient"
'With System.Net NameSpace
Dim myWebClient As New WebClient
myWebClient.DownloadFile(RemoteUrl, LocalFile)
TmpResult = True
End Select
End Function


标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:asp.net开发web项目-vss集成环境配置

下一篇:ASP.NET设计网络硬盘之删除文件夹