Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.3k views
in .NET FTP by (120 points)
Could you add to FTPClient the following method, please.

public virtual void ChDir(string dir, bool make)
{
CheckConnection(true);
FTPReply reply;
while (true)
{
reply = control.SendCommand("CWD " + dir);
if (reply.ReplyCode == "250" || !make)
break;
make = false; // don't try to create directory twice
reply = control.SendCommand("MKD " + dir);
if (reply.ReplyCode != "257")
break; // couldn't create directory
}
lastValidReply = control.ValidateReply(reply, "250");
}

1 Answer

0 votes
by (162k points)
I can see how this would be useful, however I'd like to propose an alternative that we have been considering.

bool Exists(string path)

This would be very useful for a wide range of issues, and then you could simply do:

if (!Exists(path))
MkDir(path);
ChDir(path);

which is very clear. Sorry if this sounds a bit nitpicky, but the API is very widely used and we are loathe to add new methods unless we are convinced they are required.

Categories

...