Checks if a file exsts on the server by taking a
file listing of the parent directory in the path
and comparing the results the path supplied.
Namespace: System.Net.FtpClient
Assembly: System.Net.FtpClient (in System.Net.FtpClient.dll) Version: 1.0.5064.17461
Syntax
C# |
---|
public bool FileExists(
string path
) |
Visual Basic |
---|
Public Function FileExists (
path As String
) As Boolean |
Visual C++ |
---|
public:
virtual bool FileExists(
String^ path
) sealed |
Return Value
Type:
BooleanTrue if the file exists
Implements
IFtpClient..::..FileExists(String)
Examples
C# |
Copy
|
using System;
using System.Net;
using System.Net.FtpClient;
namespace Examples {
static class FileExistsExample {
public static void FileExists() {
using (FtpClient conn = new FtpClient()) {
conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
if (conn.FileExists("/full/or/relative/path",
FtpListOption.ForceList | FtpListOption.AllFiles)) {
}
}
}
}
}
|
See Also