Sunday, July 4, 2010

FTPRenameFile

Example of FTPRenameFile

const service_ftp=1
const open_type_direct=1
const ftp_transfer_type_ascii=1

'Extern is a QuickTest object to declare an external functions
Extern.Declare miclong, "InternetOpen", "wininet.dll", "InternetOpenA",_ micString, micDWord, micString, micString, micDWord
Extern.Declare miclong, "InternetConnect", "wininet.dll", "InternetConnectA",_ micLong, micString, micInteger, micString, micString, micDWord, micDWord,_ micDWord
Extern.Declare Bool,"FtpRenameFile","wininet.dll","FtpRenameFileA", micLong,_ micString, micString
Extern.Declare micinteger, "InternetCloseHandle", "wininet.dll",_ "InternetCloseHandle", miclong

hnd_internet=Extern.InternetOpen("QTP_FTP", open_type_direct, vbnullchar,vbnullchar,0)

if hnd_internet=0 then
msgbox "Connection is Failed - 1"
Else
msgbox "Connection is Successful - 1"
End if

hnd_connection=Extern.InternetConnect(hnd_internet, "ftp.dummy.co.in", 21,"username","passs",1,0,0)

If hnd_connection=0 then
msgbox "Connection is Failed"
Else
msgbox "Connection is Successful"
End If

Extern.FtpRenameFile hnd_connection, "/tmp/no_untitled.bmp", "/tmp/XX_untitled.bmp"

Extern.InternetCloseHandle(hnd_connection)
Extern.InternetCloseHandle(hnd_internet)

FtpRenameFile Renames a file stored on the FTP server. first parameter is the Handle to an FTP connection and second parameter is the name of the file to be renamed. third paramerter contains the new name for the remote file.

Also See:
QTP FTP Main Post
FTP InternetOpen
FTP InternetConnect
FTPGetFile
FTPPutFile
FTPOpenFile
FTPSetCurrentDirectory
FTPCreateDirectory
FTPRemoveDirectory
FTPDeleteFile