Returns a file/directory listing using the NLST command.
Namespace: System.Net.FtpClient
Assembly: System.Net.FtpClient (in System.Net.FtpClient.dll) Version: 1.0.5064.17461
Syntax
C# |
---|
public string[] GetNameListing(
string path
) |
Visual Basic |
---|
Public Function GetNameListing (
path As String
) As String() |
Visual C++ |
---|
public:
virtual array<String^>^ GetNameListing(
String^ path
) sealed |
Return Value
Type:
array<String>[]()[][]A string array of file and directory names if any were returned.
Implements
IFtpClient..::..GetNameListing(String)
Examples
C# |
Copy
|
using System;
using System.Net;
using System.Net.FtpClient;
namespace Examples {
class GetNameListingExample {
public static void GetNameListing() {
using (FtpClient cl = new FtpClient()) {
cl.Credentials = new NetworkCredential("ftp", "ftp");
cl.Host = "ftp.example.com";
cl.Connect();
foreach (string s in cl.GetNameListing()) {
bool isDirectory = cl.DirectoryExists(s);
DateTime modify = cl.GetModifiedTime(s);
long size = isDirectory ? 0 : cl.GetFileSize(s);
}
}
}
}
}
|
See Also