You can use the DirectoryExists
method to check whether specified directory already exists. So the code can look like this:
if (!client.DirectoryExists(outboundDirectory))
client.CreateDirectory(outboundDirectory);
Please note, that if you are using FTP protocol, the DirectoryExists
method is not supported on all servers. In the case of such server, you have to call client.CreateDirectory(outboundDirectory) and handle potential exception.
If you are using SFTP protocol, there is no problem in using DirectoryExists
method.