ListDirectory - SftpPathNotFoundException

Nov 14, 2012 at 10:16 AM

I'm trying to list files in a directory:

public override IEnumerable<FileInfo> GetFileList() {
    
    List<FileInfo> files = new List<FileInfo>();
    foreach (SftpFile file in sftpClient.ListDirectory("mnt/hgfs/ALURequests"))
        if (!file.Name.StartsWith("."))
            files.Add(new FileInfo(directoryName + "/" + file));
    return files;
}

And getting this exception:

Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Sftp.SubsystemSession.WaitHandle(WaitHandle waitHandle, TimeSpan operationTimeout)
   at Renci.SshNet.Sftp.SftpSession.RequestOpenDir(String path, Boolean nullOnError)
   at Renci.SshNet.SftpClient.InternalListDirectory(String path, SftpListDirectoryAsyncResult asynchResult)
What am I doing wrong?

Jan 31, 2013 at 7:59 PM
Not sure if this helps, but when I wrote something to use ListDirectory, I used the SftpFile class instead of FileInfo and my first attempt worked.
IEnumerable<SftpFile> myList = new List<SftpFile>();
On the other hand, I am trying to use SynchronizeDirectories and getting nowhere. Same errors as you not above.
Coordinator
Feb 1, 2013 at 3:30 AM
Yoav,
Sorry for late response, I guess I just missed your question but unfortunately I wont be able to help there since this is an error that I am getting from the server so all I am doing is just prorogating it back to the client.

bdelaney,
As far as SynchronizeDirectories, this piece was contributed by other developer so I cant say much there but if you can provide me with test case code showing how it suppose to work I will try to look at it as soon as I can.

Thanks,
Oleg
Feb 1, 2013 at 1:07 PM
Great job on keeping up with things here Olegkap. I bet you could use some help. In particular, I think there is a lack of sample code and clear instructions. The library is HUGE and I believe a little inconsistent. (but hey, at least lots of folks are contributing :-)

I will be sure to append more details to this discussion thread as I push through using various aspects of ssh.net. In the future, if I can help with documentation, perhaps that can be my contribution.

I did get the SynchronizeDirectoriess command working. I was about ready to look at the source code when I realized it was just a matter of correctly specifying the parameters. Having no knowledge of SFTP standards hampered my understanding of the requirements.
Coordinator
Feb 1, 2013 at 1:22 PM
Hi,

Thanks,
I am glad you got it working.
Yea, I agree that needs more documentation.
Unfortunately I don't have much time for it lately and when I do have time I prefer to do fixes or some requested features.
If you want to help with sample documentation then let me know and I can add you as a developer then but would need to explain how to embedded.
I recently come up with a way to embed sample code in the project comments, reference it in test so sample code could be embedded into generated documentation but also participate in test cases.
Just thought to do two things at once :)

Thanks,
Oleg
Feb 2, 2013 at 4:44 PM
Oleg,
I'm interested in learning about the embedding of sample code in project comments, etc. What you described above sounds very efficient and would help the test effort.

I've barely touched the source code so far, but I'm looking at the SynchronizeDirectories feature today. How would I find the developer who contributed that? Say, if I had questions or wanted to generate documentation on it, or even contribute a change to it?!

For example, I did some testing and got unexpected results. I tracked it to a region of the source code "upload the difference" which has this comment:
//  TODO:   Use md5 to detect a difference
//ltang: File exists at the destination => Using filesize to detect the difference
Which in my use case makes it less useful.
I guess if I were documenting this function, I'd include a note about that.

I'm really new to Codeplex and I imagine there is some way to hunt this up in a project fork and learn who the developer is. I'll investigate a little more today. (Oh, I get it. I have to be a member of the project to use TFS, or I have to use Subversion) I'm more familiar with TFS.

I did try to use the online changeset history and look for it that way. But all of the 375 commits are owned by you and I did find 1 SynchronizeDirectories, #22075, which is a refactoring. But I'm not sure why the web-based diff tool does not present the code changes very well. http://sshnet.codeplex.com/SourceControl/changeset/22075. Maybe what I'm seeing here is that the function is added to Silverlight but already existing in the sftp.client.net?

Obviously I have a lot to learn, but this may get me to put a project up on Codeplex myself. Then I'll learn faster.

Speaking of that, I wonder how good Codeplex is about linking together 'parent-children' projects. If I use ssh.net in my project, I'll be sure to mention that.
Oh, I found one way to see if projects are connected. If another project's coordinator is following your project, it may because he is using your project. For instance, dbsend is using ssh.net but I only discovered it by looking at the author because he was following ssh.net.
Coordinator
Feb 2, 2013 at 8:31 PM
Hi,

Well, when I was using latest version of the sandcastle, I discovered that I can reference the sample code which are located in separated file(s) and more then that, I can have many different examples in one file which are separated by region.
So I figured why cant I combine my tests along with documentation. This will grantee that all my samples works.

As far as project, I used TFS before too, but I find that subversion in that case is much more convenient to use, may be its a personal preference I guess. So if you want to contribute sample, tests or both then I can add you as a developer in the project and you could check in code directly. The only thing I would ask you is to use subversion since TFS adds some additional information to project and solution files and directories.

I am not sure if its possible to find parent-child projects on codeplex but I guess I would be curios to know it myself.

If you like, you can contact me on Skype where my nick is olegkap and we can discuss more.

Thanks,
Oleg
Feb 21, 2013 at 11:50 AM
Hi Oleg,
I'm paying more attention to various discussion threads and digging deeper into SSH.NET. I'm planning to have my project on Codeplex published by end of the month. It depends heavily on SSH.NET.

Recently I was a little stymied by the two timeouts for SFTP connection, but think I have that figured out. In my stumbling around I realized that there is probably very rich Exception information which I could use. But for now, I'm rushing to get basic functionality working.
I should say I'm not a very mature OOP/.NET programmer. So it's been helpful for me to use the Object Browser and the .chm help files supplied with SSH.NET. I was looking at the Client.chm and realized what you meant about examples showing up.
While I'm really not ready to contribute much to the project, I wanted you to know I'm still interested in helping at the very least with documentation. But I'd be pretty naïve at first and I'm sure my examples would be very simplistic.
As I read over the various discussions I realize that there are quite a few excellent programmers out there using SSH.NET and they do some awesome research. More than once I've read somebody's response or analysis of an issue and thought 'If only we could crowdsource documentation out of this discussion.'
As soon as Penguin Publish is up and running on Codeplex I'll find a way to give SSH.NET all the credit it deserves. I'll pass the link to you right after I open it up to the public.
thanks again for all the work you have done on SSH.NET.
Bill Delaney

From: [email removed]
To: [email removed]
Date: Sat, 2 Feb 2013 13:31:13 -0800
Subject: Re: ListDirectory - SftpPathNotFoundException [sshnet:403150]

From: olegkap
Hi, Well, when I was using latest version of the sandcastle, I discovered that I can reference the sample code which are located in separated file(s) and more then that, I can have many different examples in one file which are separated by region. So I figured why cant I combine my tests along with documentation. This will grantee that all my samples works. As far as project, I used TFS before too, but I find that subversion in that case is much more convenient to use, may be its a personal preference I guess. So if you want to contribute sample, tests or both then I can add you as a developer in the project and you could check in code directly. The only thing I would ask you is to use subversion since TFS adds some additional information to project and solution files and directories. I am not sure if its possible to find parent-child projects on codeplex but I guess I would be curios to know it myself. If you like, you can contact me on Skype where my nick is olegkap and we can discuss more. Thanks, Oleg
Read the full discussion online.
To add a post to this discussion, reply to this email (sshnet@discussions.codeplex.com)
To start a new discussion for this project, email sshnet@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
Feb 21, 2013 at 12:12 PM
I just added you as a Skype contact.
I'm going to start a new issue on the SSH.NET discussions now because I'm confused as to using private key files.
Bill

From: [email removed]
To: [email removed]
Subject: RE: ListDirectory - SftpPathNotFoundException [sshnet:403150]
Date: Thu, 21 Feb 2013 06:49:57 -0600

From: olegkap
Hi, Well, when I was using latest version of the sandcastle, I discovered that I can reference the sample code which are located in separated file(s) and more then that, I can have many different examples in one file which are separated by region. So I figured why cant I combine my tests along with documentation. This will grantee that all my samples works. As far as project, I used TFS before too, but I find that subversion in that case is much more convenient to use, may be its a personal preference I guess. So if you want to contribute sample, tests or both then I can add you as a developer in the project and you could check in code directly. The only thing I would ask you is to use subversion since TFS adds some additional information to project and solution files and directories. I am not sure if its possible to find parent-child projects on codeplex but I guess I would be curios to know it myself. If you like, you can contact me on Skype where my nick is olegkap and we can discuss more. Thanks, Oleg
Read the full discussion online.
To add a post to this discussion, reply to this email (sshnet@discussions.codeplex.com)
To start a new discussion for this project, email sshnet@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com