Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.9k views
in .NET FTP by (160 points)
I am using edtFTPnet version 1.2.3.0 in C# 2005.

Part of the requirement is to specify whether to overwrite and existing file during a put, in order to overwrite you need to know whether the file exists for which I am using the dir(filename) command. On one FTP server it works fine, returning exactly what you would expect, but on another if the file doesn't exist it throws an FTPexception, i need to the code to work consistantly on both FTP machines.

Can you suggest anything to make it work consistantly on both machines ?

Thanks in advance

Steve

3 Answers

0 votes
by (51.6k points)
The reason why this fails is that not all servers accept an argument when you get a directory listing since that's not in the standard. Instead of this try first getting the file's size (using FTPConnection.GetSize(string)), and then if that fails, try getting its last write time (using FTPConnection.GetLastWriteTime(string)). It's possible that both of these may fail since they rely on specified extensions to the standard protocol, but it is unlikely.

- Hans (EDT)
0 votes
by (160 points)
Thanks for the reply but..

I trying using the FTPConnection.GetSize and FTPConnection.GetLastWriteTime methods but they both resulted in FTPExceptions being thrown (the same as doing an FTPClient.dir command) so I still have the problem. For the particular server which generates the errors the overwritting function isn't strictly needed (the put works fine) so I have disabled the offending code and it's running OK now, I will revisit it at some point soon.
0 votes
by (51.6k points)
Would you be able to enable logging and post the log here?

- Hans (EDT)

Categories

...