This project is read-only.

Permission Denied when calling ListDirectory

Aug 31, 2011 at 7:47 PM


I'm currently writing an app that uses SftpClient (and the ListDirectory method) to recursively list every file in every directory on a linux box.  However, whenever an SftpPermissionDeniedException is thrown, I can no longer iterate through the IEnumerable<SftpFile> to view the rest of the files or directories, even if I catch the exception.

So, when I call ListDirectory on a directory, it'll go through it, listing the files/folders within it, until it hits one that it cannot access.  I'd like for it to skip anything it can't process and just continue listing everything else in the directory, but I haven't been able to find a way to make that happen.

I've tried using the latest version of the source code (10035), but encounter the same problems.
I also figured I could go through the source, catch the exception somewhere near the place where it's thrown, then just skip it there (by calling the IEnumerator.MoveNext() method or something), but I'm kinda out of my depth and I just end up breaking everything instead. ^_^

Has anyone got any ideas for how to skip directories without everything breaking?
I'd really appreciate any help you can give.


Sep 1, 2011 at 12:03 PM

Good catch,


I will take a look at it when I am back from vacation.


Can you open it as an issue so I dont forget about it?




Sep 1, 2011 at 12:17 PM

Done.  (

Thanks, and enjoy the vacation. ;)


Sep 1, 2011 at 12:29 PM


Will do :):)