RenameFile
RenameFile renames files on the remote FTPA protocol used to transfer files between network computers. server.
Syntax
RenameFile(STRING originalFileName, STRING renamedFileName)
Where:
originalFileName
is a stringrenamedFileName
is a string
Returns
Boolean. If it returns TRUE
, the function has succeeded, otherwise it means that and error was returned. When FALSE
is returned, FTPObject.LastError
will 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