Mattw11486 Posted January 4, 2020 Posted January 4, 2020 I want the code to check to see if the file already exists on the ftp side before it copies the file over in the server to prevent overwrites. If the file does exist it loops back to step 1 on constantly checking until the file on the FTP is no longer there/deleted, then it will send the file to the FTP. I am not sure how to execute this. While 1 sleep(300) If FileExists("C:\cygwin32\home\Sapphire\cwe\lib\etc\bonus_activation.txt") Then $Open = _FTP_Open('MyFTP Control') $Conn = _FTP_Connect($Open, $server, $username, $pass) $Ftpp = _FTP_FilePut($Conn, 'C:\cygwin32\home\Sapphire\cwe\lib\etc\bonus_activation.txt', '/bonus_activation.txt') $Ftpc = _FTP_Close($Open) FileDelete("C:\cygwin32\home\Sapphire\cwe\lib\etc\bonus_activation.txt") EndIf Wend
TheXman Posted January 4, 2020 Posted January 4, 2020 (edited) Quote How to check if a file exists on the FTP side? Expand I find it hard to believe that you looked thru all of the _FTP* functions in the help file and didn't see any that may be able to tell you if a particular file exists on the FTP server, but assuming that's the case, here are a couple of ways you do it: You could use _FTP_FileGetSize and if it returns an error, then the file most likely does not exist. Of course this assumes that you supplied the appropriate file name. You could use _FTP_ListToArray after making sure that you are looking in the right directory using _FTP_DirSetCurrent. Then you could search the resulting array to see if the desired file exists. Of course both of the ways above assume that you are able to successfully connect and communicate with the FTP server. Edited January 4, 2020 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Mattw11486 Posted January 4, 2020 Author Posted January 4, 2020 (edited) I did look through the ftp functions and did not find anything that matched up to what I was looking for, then again I am new at this which is the purpose of the post, but thanks for your helpful comment. Edited January 4, 2020 by Mattw11486
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now