Permission Denied when calling ListDirectory

Aug 31, 2011 at 6:47 PM

Hey.

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.

Thanks 

Coordinator
Sep 1, 2011 at 11:03 AM

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?

 

Thanks,

Oleg

Sep 1, 2011 at 11:17 AM

Done.  (http://sshnet.codeplex.com/workitem/836).

Thanks, and enjoy the vacation. ;)

-Foam

Coordinator
Sep 1, 2011 at 11:29 AM

Thanks,

Will do :):)