WEB开发网
开发学院WEB开发ASP.NET ASPX保存远程图片到本地的两种方法的函数 阅读

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

 2005-05-31 17:01:52 来源:WEB开发网   
核心提示:Function UPRemoteFileToLocal(ByVal UpType As String, ByVal RemoteUrl As String, ByVal LocalFile As String) As Boolean Dim TmpResult As Boolean = False Select

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


 

Tags:ASPX 保存 远程

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接