Page 1 of 1

Rename files in directory ftp

Posted: Fri Aug 25, 2006 7:39 pm
by vilian
Hi,

I use class TFTP/TFTPFILE of the FWH and I am needing to rename files in directory ftp. How I can make this?

Posted: Sat Aug 26, 2006 6:55 am
by Antonio Linares
Vilian,

Please add this function to source\winapi\wininet.prg:

DLL32 FUNCTION FtpRenameFile( hFTP AS LONG, cOldFileName AS LPSTR, cNewFileName AS LPSTR ) ;
AS BOOL PASCAL ;
FROM "FtpRenameFileA" LIB hWinINet

And add this Method to Class TFtp:

METHOD RenameFile( cOldFileName, cNewFileName ) CLASS TFTP

return If( ::hFTP != nil, FtpRenameFile( ::hFTP, cOldFileName, cNewFileName ), .f. )

Posted: Sat Aug 26, 2006 1:46 pm
by vilian
Thanks antonio.

Posted: Mon Aug 28, 2006 11:57 am
by vilian
Hi Antonio,

Already I tried to use oFtp:RenameFile() informing the way, without informing, but I do not obtain to rename archives. You can help me?

Posted: Mon Aug 28, 2006 12:13 pm
by Antonio Linares
Vilian,

Please do a MsgInfo( oFTP:RenameFile( ... ) ) and lets check the returned value.

Posted: Mon Aug 28, 2006 12:17 pm
by vilian
Antonio,

It´s returned value .F.

Posted: Mon Aug 28, 2006 2:23 pm
by Antonio Linares
Vilian,

Does the FTP user have permit to rename files ?

Posted: Mon Aug 28, 2006 5:56 pm
by vilian
Hi Antonio,

I have total access to directory ftp. I execute the command thus:

oFTP:RenameFile(;
"/ premierefilmes/web/txts/bilhetes/teste.old", "teste.txt")

Also already I tested thus:

oFTP:RenameFile(;
"/premierefilmes/web/txts/bilhetes/teste.old",;
"/premierefilmes/web/txts/bilhetes/teste.txt")

Posted: Tue Aug 29, 2006 12:20 am
by vilian
Hi Antonio,

The problem with the Rename command, is that it so changes the name of archives in the current directory, or either, that to move for the directory where is located the archive before executing the Rename command.

It will be that in the WinINet.dll we have a command equivalent to the Cd() of fivewin?

Posted: Tue Aug 29, 2006 7:53 am
by Antonio Linares
Vilian,

Add this to source\winapi\wininet.prg:

Code: Select all

DLL32 FUNCTION FtpSetCurrentDirectory( hFTP AS LONG, cDirName AS LPSTR ) ;
                              AS BOOL PASCAL ;
                              FROM "FtpSetCurrentDirectoryA" LIB hWinINet
And this to Class TFtp:

Code: Select all

   METHOD SetCurrentDirectory( cDirName ) INLINE ;
            FtpSetCurrentDirectory( ::hFTP, cDirName )

Posted: Tue Aug 29, 2006 11:11 am
by vilian
Antonio,

Thanks for the evolution.