0 votes
by (140 points)

How does one create a directory only if it required does it follow the .net protocol in that the directory is only created if does not exist.

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (70.2k points)

You can use the DirectoryExists method to check whether specified directory already exists. So the code can look like this:

if (!client.DirectoryExists(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.