I want to download the specific files from SFTP server(root and Subdirectories). I am trying to get a list of files and subdirectories from SFTP recursively which i could not do. but with the following code it is only listing only files and directory names. I am trying to add the directory path to a directory of type (Renci.SshNet.Sftp.SftpFile) I am getting the following exception.

Any alternative way to handle this issue.

```
using (var sftp = new SftpClient(host, 22, username, password))
   {
      sftp.Connect();
      var directory = sftp.ListDirectory("/").ToList();
      string FileName = "Dir1/abc.txt,file1.txt,file2.txt"
      var fileNameList = FileName.Contains(',') ? FileName.Split(',') : String.IsNullOrEmpty(FileName) ? new string[0] : new string[1] { FileName };

      HashSet<string> filenameHash = new HashSet<string>(fileNameList.Select(x => x));
      directory.RemoveAll(x => !filenameHash.Contains(x.Name));
      directory.RemoveAll(x => (!x.IsRegularFile));

      string dir = "";

      SftpFile fl = (SftpFile)Convert.ChangeType(dir, typeof(SftpFile));

      foreach (var f  in fileNameList)
                {
                    if (f.Contains('/'))
                    {
                        fl += f;

                    }
                }

```

Exception:

```
System.InvalidCastException: 'Invalid cast from 'System.String' to 'Renci.SshNet.Sftp.SftpFile'.'

```