This project is read-only.

SftpClient.ListDirectory with encoding iso-8859-1

Oct 11, 2011 at 4:08 PM


i have a problem with the ListDirectory.

Our SFTP-Server has a file named "test-ü.pdf" and the SftpClient.ListDirectory method shows the SFTPFile.FullName as "test-?.pdf".
The Method SftpClient.Get with this filename throws the exception "File not found".

Any attempt with System.Text.Encoding.GetEncoding("iso-8859-1") to change the ecoding failed.

In the file SshDate.cs i have found the method ReadString where the filename will be encoded with UTF8.

How can i handle the german-filenames?

Dim iso88591 As System.Text.Encoding = System.Text.Encoding.GetEncoding("iso-8859-1")

Using uSftpClient As SftpClient = New SftpClient(My.Settings.SFTP_Server, My.Settings.SFTP_Benutzer, My.Settings.SFTP_PW)
        Dim lFileList = uSftpClient.ListDirectory(My.Settings.SFTP_RootPath)
        For Each fFile In lFileList
            Dim lFileName As String = fFile.FullName 'This Name is UTF8 Encoded
            Dim lUTF8Bytes As Byte() = Encoding.UTF8.GetBytes(lFileName)
            Dim lIso88591Bytes As Byte() = Encoding.Convert(Encoding.UTF8, iso88591, lUTF8Bytes)
            Dim lFileNameConverted = iso88591.GetString(lIso88591Bytes)
End Using




Oct 13, 2011 at 2:00 PM

Hi Holger,

Sorry for late response, currently busy with other project,

I never tried to use SSH with any other language so I dont even know how to approach it.

I guess once I have some more free time I will try to use different characters, upper ASCII codes I assume and see how it works.


I remeber I did some testing a while back with naming a file some weired name and it worked so I guess I`ll have to double check that and will let you know.

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




Oct 14, 2011 at 10:09 AM

Hi Oleg,

i have opened an issue here :


Another thing i noticed with SftpClient.ListDirectory is that the property IsRegularFile from the returning SftpFile never gets true.

The same SftpFile from a call with SftpClient.Get shows the correct value for IsRegularFile.




Oct 14, 2011 at 5:35 PM

hmm, weird,

ok, thanks,


I will look into it too, I just wonder why, since from what I remeber it handles the same routine, but may be I am wrong :(.