NET FTP Library
DeleteByDateRange Method
Example 






KellermanSoftware.NetFtpLibrary Namespace > FTP Class : DeleteByDateRange Method
The minimum file date to delete
The maximum file date to delete
If true, delete files in sub directories
Delete all files in the current FTP directory with a modification date within the specified date range
Syntax
'Declaration
 
Public Sub DeleteByDateRange( _
   ByVal minDate As System.Date, _
   ByVal maxDate As System.Date, _
   ByVal subDirectories As System.Boolean _
) 
'Usage
 
Dim instance As FTP
Dim minDate As System.Date
Dim maxDate As System.Date
Dim subDirectories As System.Boolean
 
instance.DeleteByDateRange(minDate, maxDate, subDirectories)
public void DeleteByDateRange( 
   System.DateTime minDate,
   System.DateTime maxDate,
   System.bool subDirectories
)
public procedure DeleteByDateRange( 
    minDate: System.DateTime;
    maxDate: System.DateTime;
    subDirectories: System.Boolean
); 
public function DeleteByDateRange( 
   minDate : System.DateTime,
   maxDate : System.DateTime,
   subDirectories : System.boolean
);
public: void DeleteByDateRange( 
   System.DateTime minDate,
   System.DateTime maxDate,
   System.bool subDirectories
) 
public:
void DeleteByDateRange( 
   System.DateTime minDate,
   System.DateTime maxDate,
   System.bool subDirectories
) 

Parameters

minDate
The minimum file date to delete
maxDate
The maximum file date to delete
subDirectories
If true, delete files in sub directories
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 files from yesterday until right now in the directory "test"
DateTime minDate = DateTime.Now.AddDays(-1);
DateTime maxDate = DateTime.Now;
ftp.CurrentDirectory = "test";
ftp.DeleteByDateRange(minDate, maxDate, subDirectories);
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 files from yesterday until right now in the directory "test"
Dim minDate As DateTime = DateTime.Now.AddDays(-1)
Dim maxDate As DateTime = DateTime.Now
ftp.CurrentDirectory = "test"
ftp.DeleteByDateRange(minDate, maxDate, subDirectories)
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