Reputation: 1419
I'm trying to parse the result of the Ftp.ListDirectoryDetails command, I want just the FileName and the last modification date Not Directories.
The command returns this:
"01-21-09 06:16PM rattandom" "01-21-09 08:01PM 9900 myfile.txt"
Does somebody know the way to parse it? I was reading and if the server is Windows or Unix it will return something different. The result that I paste is for an FTP in a Windows 2003 Server
Upvotes: 1
Views: 3907
Reputation: 6381
You may want to try Ftp.dll FTP component it pareses most UNIX and Windows LIST command responses:
using (Ftp client = new Ftp())
{
client.Connect("ftp.example.org");
client.Login("user", "password");
List<FtpItem> items = client.GetList();
foreach (FtpItem item in items)
{
Console.WriteLine("Name: {0}", item.Name);
Console.WriteLine("Size: {0}", item.Size);
Console.WriteLine("Modify date: {0}", item.ModifyDate);
Console.WriteLine("Is folder: {0}", item.IsFolder);
Console.WriteLine("Is file: {0}", item.IsFile);
Console.WriteLine("Is symlink: {0}", item.IsSymlink);
Console.WriteLine();
}
client.Close();
}
Please note that this is a commercial product I created.
Upvotes: 0
Reputation: 5788
There is a suggested regular exception that works on both Windows and Unix based FTP servers. See this answer.
Upvotes: 1
Reputation: 35107
FTP list results are non-standard so every FTP server could potentially return something different.
Upvotes: 4