WITH THIS.oFTP .HostName = THIS.cFTPServer .RemotePort = THIS.cFTPPort .UserName = THIS.cUserName .Password = THIS.cPassword THIS.AddTask("Connecting to server via FTP.") IF .Connect() = 0 * We connected OK THIS.AddTask("Connection successful.") THIS.AddTask("Downloading: " + tcFile) lnResult = .GetFile(THIS.cUpdatePath + JUSTFNAME(tcFile), tcLinkFile) IF lnResult <> 0 * Error .Disconnect() THIS.AddTask("Error retrieving file.") ELSE * Successful toTransfer.AddFile(ADDBS(THIS.cUpdatePath) + tcFile) IF This.DoesFTPFileExist(JUSTSTEM(tcLinkFile) + ".FPT", This.oFTP) lnResult = .GetFile(THIS.cUpdatePath + JUSTSTEM(tcFile) + ".FPT", JUSTSTEM(tcLinkFile) + ".FPT") IF lnResult <> 0 * Error .Disconnect() THIS.AddTask("Error retrieving FPT file.") ELSE .Disconnect() llError = .F. ENDIF ELSE .Disconnect() llError = .F. ENDIF ENDIF ELSE * Error .Disconnect() THIS.AddTask("An error occurred while attempting to connect to the server.") ENDIF ENDWITH -------------- FUNCTION DoesFTPFileExist LPARAMETERS tcFile, toFTP LOCAL llExist, ; lcFile, ; lcFileName * Parsing is dependent on FTP server - must be UNIX filenames, not DOS IF VARTYPE(tcFile) = "C" and VARTYPE(toFTP) = "O" lcFile = "" IF toFTP.OpenDirectory("/") = 0 toFTP.ParseList = .F. DO WHILE toFTP.Read(@lcFile, 1000) > 0 * Move on to the next one if it's a directory IF LEFT(lcFile, 1) = "d" LOOP ENDIF * Parse out the file name lcFileName = SUBSTR(lcFile, 60, LEN(lcFile) - 61) IF ALLTRIM(UPPER(tcFile)) = ALLTRIM(UPPER(lcFileName)) llExist = .T. EXIT ENDIF ENDDO toFTP.CloseDirectory() ELSE * Error ENDIF ELSE * Bad parameters ENDIF RETURN llExist