Can I run DIR Command using 'SendCommand' ?

+1 vote
asked Oct 10, 2017 by Harsh
retagged Oct 10, 2017 by Limilabs support

1 Answer

0 votes

Why would you want to do that?

DIR is Windows command prompt command. You should use appropriate FTP command:

using (Ftp client = new Ftp())
{
    client.Connect("ftp.example.org");
    client.Login("user", "password");

    client.ChangeFolder("reports");

    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();
}

Appropriate FTP command is going to be issued: LIST, MLST and response parsed.

answered Oct 10, 2017 by Limilabs support (230,760 points)
Questoin about DIR / LIST / GetList() method.
...