NET FTP Library
DeleteFile Method
Example 






KellermanSoftware.NetFtpLibrary Namespace > FTP Class : DeleteFile Method
The file to delete
Delete a file in the current FTP directory
Syntax
'Declaration
 
Public Function DeleteFile( _
   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.DeleteFile(fileName)
public System.bool DeleteFile( 
   System.string fileName
)
public function DeleteFile( 
    fileName: System.String
): System.Boolean; 
public function DeleteFile( 
   fileName : System.String
) : System.boolean;
public: System.bool DeleteFile( 
   System.string* fileName
) 
public:
System.bool DeleteFile( 
   System.String^ fileName
) 

Parameters

fileName
The file to delete

Return Value

True if the file is successfully deleted OR the file does not exist
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
 
//Delete a file in the current FTP directory 
System.Console.WriteLine("We are trying to delete TestFile");
 
bool status = ftp.DeleteFile("TestFile");
 
System.Console.WriteLine("TestFile {0} deleted", status == true ? "has been" : "could not be");
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
 
'Delete a file in the current FTP directory
System.Console.WriteLine("We are trying to delete TestFile")
 
Dim status As Boolean = ftp.DeleteFile("TestFile")
 
If status = True Then
    System.Console.WriteLine("TestFile {0} deleted","has been")
Else
    System.Console.WriteLine("TestFile {0} deleted","could not be")
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