Dec 31, 2010 at 4:39 PM
Edited Dec 31, 2010 at 4:40 PM
The SFTP spec that I used was here:
http://tools.ietf.org/html/draft-ietf-secsh-filexfer-02. Section 5 says "The `permissions' field contains a bit mask of file permissions as defined by posix
". They refer to a document that does not appear to be relevant.
I got the values of the S_IFDIR flag from here:
http://en.wikipedia.org/wiki/Sys/stat.h. The Wikipedia description says "<sys/stat.h> is the header in the
C POSIX library for the
C programming language that contains constructs that facilitate getting information about files attributes", which appears to be quite relevant.
I have modified my copy of SftpFile.cs as follows:
/// Represents SFTP file information
public class SftpFile
// POSIX Permission bit mask
private const int S_IFDIR = 16384;
/// Gets whether this object is a directory
public Boolean IsDirectory
return ((this.Permissions & S_IFDIR) == S_IFDIR);
I have also modified my copy of SftpClient.cs as follows:
public class SftpClient : BaseClient
/// Retrieves list of files (only) in remote directory.
/// <param name="path">The path.</param>
/// <returns>List of directory entries</returns>
public IEnumerable<SftpFile> GetFiles(string path)
// Get a raw listing of files and directories
IEnumerable<SftpFile> listDirectory = this.ListDirectory(path);
// Filter the list to a list of files only
var getFiles = (from sftpFile in listDirectory
where sftpFile.IsDirectory == false
I chose the method name "GetFiles()" to mirror the System.IO.DirectoryInfo.GetFiles() method.