FindFirstFile
FindFirstFile initiates and enumeration of files and directories in the current directory on the remote FTPA protocol used to transfer files between network computers. server.
Syntax
FindFirstFile(STRING filemask)
Where:
Filemaskis a string. Usually this would be “*” to enumerate all files.
Returns
- Boolean. If it returns
TRUE, that means that at least one file on the remote FTP server matched - File name and file size for the first matching file can be retrieved using
GetFindFileName()andGetFindFileSize()methods. FindNextFile()method is used to move to next matching fileFindFirstFilewill returnsFALSEin case no matching files were foundFindFirstFilewill also returnsFALSEon subsequent calls toFindFirstFile()if current search operation has not been closed withFindFileClose()method- When
FALSEis returned,FTPObject.LastErrorwill return the WIN32 error code.
Example
An example of RenameFile function in the FTP Object. Renames all files found in the root of the FTP server:
Function Main
Dim FTPobj as Object
Const DIRECTORYMASK=&H10
ip = "127.0.0.1"
port = 21
cr = Chr(13) + Chr(10)
Set FTPobj = FTP.Connect (ip,port,TRUE,"anonymous","lnss@gfi.com")
Found=FTPobj.FindFirstFile("*")
While Found
If (FTPobj.GetFindFileAttributes And DIRECTORYMASK) = DIRECTORYMASK Then
FileType="directory"
Else
FileType="file"
FileName = FTPobj.GetFindFileName
RenameFileName = "renamed_" + FTPobj.GetFindFileName
ret = FTPobj.RenameFile (FileName, RenameFileName)
End If
echo "File: " + FTPobj.GetFindFileName + " size: " + CStr(FTPobj.GetFindFileSize) + " bytes type: " + FileType & cr
Found=FTPobj.FindNextFile
Wend
End Function