Directory Exists |
Checking if a directory exists on the FTP server.
[C#]
// create new Ftp instance
Ftp ftp = new Ftp(hostname, username, password, port);
// establish connection
ftp.Connect();
String directory = "directoryname.txt";
// detects whether the specified directory exists.
if (ftp.DirectoryExists(directory)) {
Console.WriteLine("The directory {0} exists", directory);
} else {
Console.WriteLine("The directory {0} not exists", directory);
}
[Visual Basic]
' create new Ftp instance
Dim ftp As Ftp = New Ftp(hostname, username, password, port)
' establish connection
ftp.Connect()
Dim directory As String = "directoryname.txt"
' detects whether the specified directory exists.
If ftp.DirectoryExists(directory) Then
Console.WriteLine("The directory {0} exists", directory)
Else
Console.WriteLine("The directory {0} not exists", directory)
End If