Rename files in directory ftp

Post Reply
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Rename files in directory ftp

Post 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?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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. )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Post by vilian »

Thanks antonio.
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Post 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?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Vilian,

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

Antonio Linares
www.fivetechsoft.com
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Post by vilian »

Antonio,

It´s returned value .F.
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Vilian,

Does the FTP user have permit to rename files ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Post 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")
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Post 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?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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 )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Post by vilian »

Antonio,

Thanks for the evolution.
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Post Reply