Click here to Skip to main content
15,921,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wonder if anyone can point me in the correct direction code wise. I am trying to upload file to a SFTP server. Just found out that WebRequestMethods does not do this. FTP no bother but not SFTP.

Was getting the error "remote name could not be resolved at Dim strz As System.IO.Stream = request.GetRequestStream()

As you can see, it is pretty standard stuff but need a wee bit of advice using SFTP or put me in the right direction.

What I have tried:

Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://sftp.mySFTPserver/Test.txt"), System.Net.FtpWebRequest)

request.Credentials = New System.Net.NetworkCredential(sFtpUserName, sFTpPassword)

request.Method = System.Net.WebRequestMethods.Ftp.UploadFile

Dim file() As Byte = System.IO.File.ReadAllBytes("C:\test.txt")

Dim strz As System.IO.Stream = request.GetRequestStream()

Try
strz.Write(file, 0, file.Length)
strz.Close()
strz.Dispose()
Catch ex As Exception
MsgBox(Err.Description)
End Try
Posted
Updated 10-Jan-17 3:13am
Comments
Afzaal Ahmad Zeeshan 10-Jan-17 10:39am    
That just means your client cannot access the peer device in the network.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900