当前位置:开发者网络 >> 技术教程 >> ASP教程 >> 远程脚本 >> 内容
精彩推荐
分类最新教程
分类热点教程
  
ASPX保存远程图片到本地的两种方法的函数
作者:未知
日期:2005-06-01
人气:
投稿:(转贴)
来源:未知
字体:
收藏:加入浏览器收藏
以下正文:
 

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


相关文章: