<% '******************************************************* **************************** 'PageName: getRemoteFiles.asp'Function: Download The Files To Server'Author: xiaotian'Last Modified AT: 2003-3-19 '*************************************************** ****************************************
'Get Remote Files and save to local Function GetRemotefiels (RemotePath, LocalPath, FileName) DIM STRBODYDIM FILEPATH
ON Error ResMe next
'Save StrBody = getBody (RemotePath)' acquired saved file name if right (localpath, 1) <> "/" Then localpath = localpath & "filepath = localpath & getFileName (remotepath, filename) 'Save File If SaveTofile (strbody, filepath) = true and err.number = 0 Then getRemoteFiles = true else getremotefiles = false endiff
END FUNCTION
'Remote Get Content Function GetBody (URL) DIM RETRIEVAL' Establishing XMLHTTP Object Set Retrieval = CreateObject ("Microsoft.xmlhttp") with retrieval .Open "Get", URL, FALSE, "," "" "" With set retrieval = Nothing end function
'Recombination file name Function GetFileName (RemotePath, FileName) Dim arrTmpDim strFileExt arrTmp = Split (RemotePath, ".") StrFileExt = arrTmp (UBound (arrTmp)) GetFileName = FileName & "." & StrFileExtEnd Function
'Save the flow content as file Function Savetofile (Stream, FilePath) DIM OBJSTREAM
ON Error ResMe next
'Create ADODB.Stream object must be above ADO 2.5 Set objStream = Server.CreateObject ( "ADODB.Stream") objStream.Type = 1' objStream.Open objstream.write Stream objstream.SaveToFile FilePath opened in binary mode, 2 objstream .Close () 'Close object, release resource set objstream = Nothingif Err.Number <> 0 Then Savetofile = false else savetofile = true end ingnd function%>