ListDirectory only returns directories and not files

Advertisement

menzo
Guest

ListDirectory only returns directories and not files

If I use WinSCP GUI client, I am connected to the default directory of the SFTP server and I can see the single file it contains.

However, if I use C# and connect to the same exact server then use ListDirectory(".") I only receive the ".." and the current directory name. No matter what I try it seems I am not able to view the file.

What is the trick I am missing?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
31,103
Location:
Prague, Czechia

Re: ListDirectory only returns directories and not files

That's probably some peculiarity of your FTP server.
Try doing session.ListDirectory(session.HomePath)

Reply with quote

Guest

Re: ListDirectory only returns directories and not files

The customer is using VShell from Vandyke using SFTP-3/SSH-2

File transfer protocol = SFTP-3
Cryptographic protocol = SSH-2
SSH implementation = SftpSSHD_1.4.31_Comments
Encryption algorithm = aes
Compression = No

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
31,103
Location:
Prague, Czechia

Re: ListDirectory only returns directories and not files

So did you try, what I have proposed?

Reply with quote

Guest

Re: ListDirectory only returns directories and not files

I did try and after some digging I see why WinSCP client works one way any my program works differently.

In the WinSCP tool I specify the directory to be /HOME_SFTP_DIR/LOC_OF_FILE

When I use C# I login and I am taken to /HOME_SFTP_DIR and of course the listing is only the directory.
However, I cannot figure out the command to change directory to /LOC_OF_FILE so then I can do a listing to see if there is anything for me to download.
So, I solved my first problem which was me, but I cannot figure out how to change directories.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
31,103
Location:
Prague, Czechia

Re: ListDirectory only returns directories and not files

Try session.ListDirectory(session.HomePath + "/")

Reply with quote

Advertisement

You can post new topics in this forum