'==================================================
'过程名:SaveRemoteFile
'作用:保存远程的文件到本地
'参数:LocalFileName------本地文件名
'参数:RemoteFileUrl------远程文件URL
'==================================================
FunctionSaveRemoteFile(LocalFileName,RemoteFileUrl)
SaveRemoteFile=True
dimAds,Retrieval,GetRemoteData
OnErrorResumeNext
SetRetrieval=Server.CreateObject("Microsoft.XMLHTTP")
WithRetrieval
.Open"Get",RemoteFileUrl,False,"",""
.Send
If.Readystate<>4or.Status>300then
SaveRemoteFile=False
ExitFunction
EndIf
GetRemoteData=.ResponseBody
EndWith
SetRetrieval=Nothing
'IfLenB(GetRemoteData)<100ThenExitFunction
'IfMaxFileSize>0Then
'IfLenB(GetRemoteData)>5000ThenExitFunction
Response.Write(Round(LenB(GetRemoteData)/1024))&"KB"
'EndIf
SetAds=Server.CreateObject("Adodb.Stream")
WithAds
.Type=1
.Open
.WriteGetRemoteData
.SaveToFileserver.MapPath(LocalFileName),2
.Cancel()
.Close()
EndWith
IfErr.number<>0then
SaveRemoteFile=False
ExitFunction
Err.Clear
EndIf
SetAds=nothing
endFunction