NET FTP Library
FileExists Method
Example 






KellermanSoftware.NetFtpLibrary Namespace > FTP Class : FileExists Method
The FTP file name
Check to see if a file exists in the current FTP directory
Syntax
'Declaration
 
Public Function FileExists( _
   ByVal fileName As System.String _
) As System.Boolean
'Usage
 
Dim instance As FTP
Dim fileName As System.String
Dim value As System.Boolean
 
value = instance.FileExists(fileName)
public System.bool FileExists( 
   System.string fileName
)
public function FileExists( 
    fileName: System.String
): System.Boolean; 
public function FileExists( 
   fileName : System.String
) : System.boolean;
public: System.bool FileExists( 
   System.string* fileName
) 
public:
System.bool FileExists( 
   System.String^ fileName
) 

Parameters

fileName
The FTP file name

Return Value

True if the file exists in the current FTP directory
Example
FTP ftp = new FTP(); //Trial Mode            
//FTP ftp = new FTP("place user name here", "place license key here");
 
// set the name of the FTP server( its URL )
ftp.HostAddress = "ftp.fsz.bme.hu"; // a hungarian university. change this to your ftp server
ftp.UserName = "anonymous"; // replace with your user name
ftp.Password = "user@mail.com"; // replace with your password
 
//Check to see if a file exists in the current FTP directory 
bool status = ftp.FileExists("a.txt");
 
System.Console.WriteLine("a.txt {0} on the server", status == true ? "exists" : "does not exist");
Dim ftp As FTP = New FTP() 'Trial Mode
'FTP ftp = new FTP("place user name here", "place license key here");
 
' set the name of the FTP server( its URL )
ftp.HostAddress = "ftp.fsz.bme.hu" ' a hungarian university. change this to your ftp server
ftp.UserName = "anonymous" ' replace with your user name
ftp.Password = "user@mail.com" ' replace with your password
 
'Check to see if a file exists in the current FTP directory
Dim status As Boolean = ftp.FileExists("a.txt")
 
If status = True Then
    System.Console.WriteLine("a.txt {0} on the server","exists")
Else
    System.Console.WriteLine("a.txt {0} on the server","does not exist")
End If
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

FTP Class
FTP Members