NET SFTP Library
DownloadDirectoryAsync(String,String,Boolean,Regex,Object) Method
Example 






KellermanSoftware.NetSFtpLibrary Namespace > SFTP Class > DownloadDirectoryAsync Method : DownloadDirectoryAsync(String,String,Boolean,Regex,Object) Method
The local path to put the directory
The FTP directory to download
Download files in sub directories
Regular Expression
Your custom object to be returned with Started, Progress, and Completed Events
Download files matching the regular expression.
Syntax
'Declaration
 
Public Overloads Sub DownloadDirectoryAsync( _
   ByVal localDirectory As System.String, _
   ByVal ftpDirectory As System.String, _
   ByVal subDirectories As System.Boolean, _
   ByVal regularExpression As System.Text.RegularExpressions.Regex, _
   ByVal customObject As System.Object _
) 
'Usage
 
Dim instance As SFTP
Dim localDirectory As System.String
Dim ftpDirectory As System.String
Dim subDirectories As System.Boolean
Dim regularExpression As System.Text.RegularExpressions.Regex
Dim customObject As System.Object
 
instance.DownloadDirectoryAsync(localDirectory, ftpDirectory, subDirectories, regularExpression, customObject)
public void DownloadDirectoryAsync( 
   System.string localDirectory,
   System.string ftpDirectory,
   System.bool subDirectories,
   System.Text.RegularExpressions.Regex regularExpression,
   System.object customObject
)
public procedure DownloadDirectoryAsync( 
    localDirectory: System.String;
    ftpDirectory: System.String;
    subDirectories: System.Boolean;
    regularExpression: System.Text.RegularExpressions.Regex;
    customObject: System.TObject
); 
public function DownloadDirectoryAsync( 
   localDirectory : System.String,
   ftpDirectory : System.String,
   subDirectories : System.boolean,
   regularExpression : System.Text.RegularExpressions.Regex,
   customObject : System.Object
);
public: void DownloadDirectoryAsync( 
   System.string* localDirectory,
   System.string* ftpDirectory,
   System.bool subDirectories,
   System.Text.RegularExpressions.Regex* regularExpression,
   System.Object* customObject
) 
public:
void DownloadDirectoryAsync( 
   System.String^ localDirectory,
   System.String^ ftpDirectory,
   System.bool subDirectories,
   System.Text.RegularExpressions.Regex^ regularExpression,
   System.Object^ customObject
) 

Parameters

localDirectory
The local path to put the directory
ftpDirectory
The FTP directory to download
subDirectories
Download files in sub directories
regularExpression
Regular Expression
customObject
Your custom object to be returned with Started, Progress, and Completed Events
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
 
//Downloads all directories, subdirectories and files in the selected Directory asynchronously from FTP 
System.Console.WriteLine("We are downloading the TestDir folder.This is a non-blocking call");
 
// All these calls do the same thing
sftp.DownloadDirectory("TestDir", "C:\\Download");
/* sftp.DownloadDirectory("TestDir", "C:\\Download", true, "*.*");
 sftp.DownloadDirectory("TestDir", "C:\\Download", true, new Regex(".+"));
 sftp.DownloadDirectory("TestDir", "C:\\Download", true, DateTime.MinValue, DateTime.MaxValue);
 sftp.DownloadDirectory("TestDir", "C:\\Download", true, 0, Int64.MaxValue);
  */
 
while (sftp.IsBusy == true)
{
    System.Threading.Thread.Sleep(100);
}
 
System.Console.WriteLine("{0} files have been Transferred", sftp.FileCount);
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
 
'Downloads all directories, subdirectories and files in the selected Directory asynchronously from FTP 
System.Console.WriteLine("We are downloading the TestDir folder.This is a non-blocking call")
 
' All these calls do the same thing
sftp.DownloadDirectory("TestDir", "C:\\Download")
' sftp.DownloadDirectory("TestDir", "C:\\Download", true, "*.*");
 'sftp.DownloadDirectory("TestDir", "C:\\Download", true, new Regex(".+"));
 'sftp.DownloadDirectory("TestDir", "C:\\Download", true, DateTime.MinValue, DateTime.MaxValue);
 'sftp.DownloadDirectory("TestDir", "C:\\Download", true, 0, Int64.MaxValue);
  '
 
Do While sftp.IsBusy = True
    System.Threading.Thread.Sleep(100)
Loop
 
System.Console.WriteLine("{0} files have been Transferred", sftp.FileCount)
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
Overload List