NET FTP Library
GetDirectoryListing() Method
Example 






KellermanSoftware.NetFtpLibrary Namespace > FTP 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 FTP
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
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
 
//Return a list of the files and dirs in the current ftp directory 
List<FTPFileInfo> files = ftp.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 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
 
'Return a list of the files and dirs in the current ftp directory
List And lt
FTPFileInfo And gt
files = ftp.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

FTP Class
FTP Members
Overload List