How to add a port on sftp connection using vb.net?

I cannot figure out how to use a specific port on my sftp connection, for example port 2023.

I found an answer about how to connect to sftp using vb.net in this topic:
Upload file to SFTP server using VB.NET

And I use the code below:

    Dim client As SftpClient = New SftpClient("example.com", "username", "password")
client.Connect()

Using stream As Stream = File.OpenRead("C:\local\path\some.csv")
    client.UploadFile(stream, "/remote/path/some.csv")
End Using

I tried this:

Dim client As SftpClient = New SftpClient("example.com", "username", "password",2023)

But I get the error:

Specifier value cannot be grater than 65535. Parameter name: port.

  • 2

    Shouldn’t it be new SftpClient([host], [port], [username], [password])?

    – 

  • omg… Yes that’s the answer! Long time working is the biggest enemy !!!

    – 

Leave a Comment