NET SFTP Library
GetDirectoryListing() Method
Example 






KellermanSoftware.NetSFtpLibrary Namespace > SFTP Class > GetDirectoryListing Method : GetDirectoryListing() Method
Return a list of the files in the current ftp directory
Syntax
'Declaration
 
Public Overloads Function GetDirectoryListing() As System.Collections.Generic.List(Of FTPFileInfo)
'Usage
 
Dim instance As SFTP
Dim value As System.Collections.Generic.List(Of FTPFileInfo)
 
value = instance.GetDirectoryListing()
public System.Collections.Generic.List<FTPFileInfo> GetDirectoryListing()
public function GetDirectoryListing(): System.Collections.Generic.List; 
public function GetDirectoryListing() : System.Collections.Generic.List;
public: System.Collections.Generic.List<FTPFileInfo*>* GetDirectoryListing(); 
public:
System.Collections.Generic.List<FTPFileInfo^>^ GetDirectoryListing(); 
Example
SFTP sftp = new SFTP(); //Trial Mode            
//SFTP sftp = new SFTP("place user name here", "place license key here");
 
// set the name of the SFTP 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
 
//Return a list of the files and dirs in the current ftp directory 
List<FTPFileInfo> files = sftp.GetDirectoryListing();
 
System.Console.WriteLine("Listing the files/dirs in the current FTP directory");
 
foreach (FTPFileInfo fi in files)
{
    System.Console.WriteLine("{0} --  {1} ", fi.FileName, fi.IsDirectory);
}
Dim sftp As SFTP = New SFTP() 'Trial Mode
'Dim sftp = New SFTP("place user name here", "place license key here")
 
' set the name of the SFTP 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
 
'Return a list of the files and dirs in the current ftp directory
List And lt
FTPFileInfo And gt
files = sftp.GetDirectoryListing()
 
System.Console.WriteLine("Listing the files/dirs in the current FTP directory")
 
For Each fi As FTPFileInfo In files
   System.Console.WriteLine("{0} --  {1} ", fi.FileName, fi.IsDirectory)
Next fi
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