Gets a file listing from the server. Each FtpListItem object returned
contains information about the file that was able to be retrieved. If
a DateTime property is equal to DateTime.MinValue then it means the
date in question was not able to be retrieved. If the Size property
is equal to 0 then it means the size of the object could also not
be retrieved.
Namespace: System.Net.FtpClient
Assembly: System.Net.FtpClient (in System.Net.FtpClient.dll) Version: 1.0.5064.17461
Syntax
C# |
---|
public FtpListItem[] GetListing(
string path
) |
Visual Basic |
---|
Public Function GetListing (
path As String
) As FtpListItem() |
Visual C++ |
---|
public:
virtual array<FtpListItem^>^ GetListing(
String^ path
) sealed |
Return Value
Type:
array<FtpListItem>[]()[][]An array of FtpListItem objects
Implements
IFtpClient..::..GetListing(String)
Examples
C# |
Copy
|
using System;
using System.Net;
using System.Net.FtpClient;
namespace Examples {
static class GetListingExample {
public static void GetListing() {
using (FtpClient conn = new FtpClient()) {
conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
foreach (FtpListItem item in conn.GetListing(conn.GetWorkingDirectory(),
FtpListOption.Modify | FtpListOption.Size)) {
switch (item.Type) {
case FtpFileSystemObjectType.Directory:
break;
case FtpFileSystemObjectType.File:
break;
case FtpFileSystemObjectType.Link:
if (item.LinkTarget != null) {
item.LinkObject = conn.DereferenceLink(item);
if (item.LinkObject != null) {
}
}
break;
}
}
foreach (FtpListItem item in conn.GetListing(conn.GetWorkingDirectory(),
FtpListOption.Modify | FtpListOption.Size | FtpListOption.DerefLinks)) {
switch (item.Type) {
case FtpFileSystemObjectType.Directory:
break;
case FtpFileSystemObjectType.File:
break;
case FtpFileSystemObjectType.Link:
if (item.LinkObject != null) {
}
break;
}
}
}
}
}
}
|
See Also