cnFTP Issues

Forums for specific tips, techniques and example code
WillieJ
Posts: 4
Joined: Fri Apr 13, 2018 11:03 am

cnFTP Issues

Postby WillieJ » Fri Nov 16, 2018 1:47 pm

Hi, just wondering if anyone is using the cnFTP class with success? I'm finding I can do basic file downloads and directory listings but cannot get renaming or deleting to work. Here's an example of the code I'm using for the delete....

mFTPDeleteFile(aServerIP, aUserName, aPassword, ftpFolder, fileName: String): String;
vars
ftp : CnFtp;
result : String;
kc : CnKarmaCntrl;
cc : CnCntrl;
begin
create kc;
cc := app.myCnCntrl;

create ftp transient ;
ftp.setModeAscii(true);
ftp.setServerName(aServerIP) ;
ftp.setUserId(aUserName,aPassword') ;
result := ftp.cnConnect ;
if result <> CN_OK then
return result;
endif;
ftp.emFtpSetCurrentDirectory(ftp.connectionHandle, ftpFolder);
result := ftp.emFtpDeleteFile(ftp.connectionHandle, fileName).String;
ftp.cnCloseSession;
epilog
return result;
delete ftp;
delete kc;
delete cc;
end;

TIA
Willie

baza
Posts: 3
Joined: Wed Dec 20, 2017 2:44 pm

Re: cnFTP Issues

Postby baza » Mon Nov 19, 2018 2:02 pm

We certainly do file deletes this way to archive old data from or servers...

If you log on to the ftp server with them same credientials using a ftp client can you delete the file ? Maybe permission issue ?

We also check the return value at the emFtpSetCurrentDirectory command,what result is returned from the emFtpSetCurrentDirectory & emFtpDeleteFile ?

also we do a cnCloseConnection rather than a cnCloseSession, and set ftp.passive := false; before the connect

happy to send you some code samples if you need them...

Cheers,
Baz

WillieJ
Posts: 4
Joined: Fri Apr 13, 2018 11:03 am

Re: cnFTP Issues

Postby WillieJ » Tue Nov 20, 2018 3:19 pm

Thanks for that Baz,

As far as I can tell it's not permissions, I can indeed delete files using WINSCP with the same credentials. But I'm NOT setting passive mode so that's
given me something to work with, also checking that the set current directory has worked, it should be there (home folder) by default but if I'm getting an error changing it then all bets are off as to where it ends up. I might come back to you about a code sample but will see how I go with what you've told me first, again thanks.

Willie


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 16 guests