NET SFTP Library
DeleteByDateRange Method
Example 






KellermanSoftware.NetSFtpLibrary Namespace > SFTP 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 SFTP
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
SFTP sftp = new SFTP(); //Trial Mode            
            //SFTP sftp = new SFTP("place user name here", "place license key here");
             
            // set the name of the SSH server( its URL )
            sftp.HostAddress = "some.sftp.server.com"; // replace with your SFTP server
            sftp.UserName  = "anonymous"; // replace with your user name
            sftp.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;
            sftp.CurrentDirectory = "test";
            sftp.DeleteByDateRange(minDate, maxDate, subDirectories);
Dim sftp As SFTP = New SFTP() 'Trial Mode
            'Dim sftp As SFTP = New SFTP("place user name here", "place license key here");
             
            ' set the name of the SSH server( its URL )
            sftp.HostAddress = "some.sftp.server.com" ' replace with your SFTP server
            sftp.UserName  = "anonymous" ' replace with your user name
            sftp.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
            sftp.CurrentDirectory = "test"
            sftp.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

SFTP Class
SFTP Members