Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.5k views
in .NET FTP by (240 points)
Hi,

I need to check to see if a file exists before uploading, I use the following code

FTPConnection ftp = new FTPConnection();   
ftp.ServerAddress = host;
ftp.UserName = user;
ftp.Password = password;
ftp.Connect();

if (!ftp.Exists("file1"))
{
   // upload file
}


If the file is not there I will get exception "Unable to determine if 'file1' exists.", but if the file is there it will work.

I'm using edtFTPnet v1.3. Thanks.

5 Answers

0 votes
by (51.6k points)
Interesting. Could you please post a DEBUG level log?

- Hans(EnterpriseDT)
0 votes
by (240 points)
Thanks. Here is the log:

DEBUG [FTPControlSocket] 25 Nov 2008 16:27:35.703 : ---> SIZE test.txt
DEBUG [FTPControlSocket] 25 Nov 2008 16:27:36.125 : 550 Access denied.
DEBUG [FTPClient] 25 Nov 2008 16:27:36.125 : SIZE not supported
DEBUG [FTPControlSocket] 25 Nov 2008 16:27:36.140 : ---> MDTM test.txt
DEBUG [FTPControlSocket] 25 Nov 2008 16:27:36.484 : 550 Access denied.
DEBUG [FTPClient] 25 Nov 2008 16:27:36.484 : MDTM not supported
DEBUG [FTPControlSocket] 25 Nov 2008 16:27:36.484 : ---> PORT 172,16,40,211,23,174
DEBUG [FTPControlSocket] 25 Nov 2008 16:27:36.828 : 200 PORT command successful.
DEBUG [FTPControlSocket] 25 Nov 2008 16:27:36.828 : ---> RETR test.txt
DEBUG [FTPControlSocket] 25 Nov 2008 16:27:37.265 : 550 Access denied.
WARN [FTPClient] 25 Nov 2008 16:27:37.265 : Unable to determine if file 'test.txt' exists.
DEBUG [FTPControlSocket] 25 Nov 2008 16:27:39.546 : ---> QUIT
DEBUG [FTPControlSocket] 25 Nov 2008 16:27:39.890 : 221 Goodbye. Control connection closed.
0 votes
by (162k points)
You get access denied for every operation.

You might need to try using GetFiles() and inspecting the list
0 votes
by (240 points)
Yes that's what I ended up doing.

BTW do you know why I'm getting the access deny error? Is it the FTP server? Thanks
0 votes
by (162k points)
Yes, that's the message sent by the FTP server. So for some reason your account doesn't permit you to do those operations on that file.

Categories

...