WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WinInet
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

FTP File Exist

 Keywords: ftp file exist fileexist iFTPFileExist 

Question:

I see there is currently no iFtpFileExist function in the Wininet Extender. I want to check if a specific file exists on my FTP server. How can I accomplish this?

Answer:

Here is some Wininet code to check if a specific files exists on your FTP server:
host = 'ftp.server.com'
user = 'fred'
pswd = 'flintstone'
ftppath = '/usr/home/bedrock/'
file = 'pebbles.zip'

AddExtender( 'WWINT44I.DLL' )
tophandle = iBegin( 0, '', '' )
conhandle = iHostConnect( tophandle, host, @FTP, user, pswd )
If conhandle == 0
   Message( 'ERROR', 'Unable to connect to host' )
   Exit
EndIf
srchhandle = iFtpFindInit( conhandle, ftppath, file, @FALSE, @FALSE )
If srchhandle == 0
   Message('IFtpFindInit?','Failed')
   Exit
EndIf
file=iFtpFindNext(@FALSE)
If file==''
   Message( 'FTP File Exist', 'File Does not Exist' )
Else
   Message( 'FTP File Exist', 'File Exists' )
EndIf

iClose( srchhandle )
iClose( conhandle )
iClose( tophandle )
Exit

Article ID:   W17379
File Created: 2008:04:10:15:08:50
Last Updated: 2008:04:10:15:08:50