FTP check if file already exists

Just starting out? Need help? Post your questions and find answers here.
Amor_2001
User
User
Posts: 11
Joined: Tue Apr 16, 2013 7:37 am

FTP check if file already exists

Post by Amor_2001 »

Hello,

how can I check if a file already exists on an FTP server with a function similar to FileSize() in a normal Directoy ?

Best Regards
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: FTP check if file already exists

Post by Shield »

Just open a connection, navigate to the target directory and check with ExamineFTPDirectory()
whether there is a file with the specific name you're looking for. Examples can be found in the help file. :wink:
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
Amor_2001
User
User
Posts: 11
Joined: Tue Apr 16, 2013 7:37 am

Re: FTP check if file already exists

Post by Amor_2001 »

The method with ExamineFTPDirectory () I have already tried. I have about 200 files in a array that I need to check. This takes quite a long time.
Here's an example of my code:

for i=1 to FileCount
If ExamineFTPDirectory(1)
While NextFTPDirectoryEntry(1)
If LCase(FTPDirectoryEntryName(1)) = Lcase(Filename(i))
Debug "File "+Filename(i)+" exist"
Continue
Else
Debug "File "+Filename(i)+" not exist"
EndIf
Wend
EndIf
Next

The code does not run correctly. Can you help me?
Post Reply