This project is read-only.

ListDirectory issues

Oct 3, 2011 at 9:53 PM

I have run into two issues using ListDirectory:

  1. Bad Packet Length Error when there are a lot of files in the directory.
  2. Awkward kludge needed to download subset of all files in a directory.

The code I am using is generally similar to that posted by tfsmag at the following link:

I am downloading from a directory which has 480 files in it for 145 MB, with no subdirectories.  When I try to do the listing it gives me the packet length error.  I was able to get around this by  adding a file pattern to the directory parameter, ie

files = client.ListDirectory("/outgoing/XYZ*");

However doing that gave me an exception that the file was not found on the server.

The reason for this was that FullName property was not being set like I would have expected.  I would have expected to see a value of

"/outgoing/XYZ20110930.dat".  Instead I was seeing a value of 

I was able to get around this by concatenating the Name parameter onto the name of the remote directory instead of using the Fullname property.

Of course I would like to know if the packet length exception was a bug or if there is a better way of listing the directory.




Oct 13, 2011 at 1:53 PM
Edited Oct 13, 2011 at 2:01 PM

Sorry for late response, currently busy with other project,

Thanks for reporting it,

It sounds to me like a bug,

I will take a look at it as soon as I have some free time again.

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




Nov 22, 2011 at 2:44 AM

I did some investigation regarding wild chars and its not supported by SFTP protocol as it is.

What PSFTP does for example is downloads full directory and the filters out the results based on the wild char provided as part of the path.

So I guess I could implement this feature eventually but dont know how importnat it is.

If you can, submit it as a feature request in "Issue Tracker" and I will try to get to it either later or if few more people are interesting in this.


As far as "Bad Packet Length", can you consistnly reproduce this error? If so can you submit your code and possible directory structure that you use, or at least number of directories/files you trying to list.

I have a test where I bring 10000 directory items and it works fine, a little slow, but works, so I just wondering if you doing something different or may be its a little different issue.




Aug 12, 2014 at 7:17 PM
Any news on this issue?

Some how my ListDirectory is returning "No Such File" on some servers and not on anothers.
My test server works good with wild chars but the same test on production server gives me the exception.

Please help me to know how I can overcome this problem.

Thank you