Click here to Skip to main content
15,894,720 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've been doing this for almost one week. But couldn't find any progress.. I'm trying to connect a secured FTP.

Here is my code..
VB
Dim sftpurl as New Uri("ftp://uname:pword@hostname:22")

Dim req As FtpWebRequest = CType(WebRequest.Create(sftpurl), FtpWebRequest)

req.Method = WebRequestMethods.Ftp.ListDirectoryDetails

req.KeepAlive = False

req.EnableSsl = True

Dim res as FtpWebResponse = req.GetResponse()

Dim stmRdr As StreamReader = New StreamReader(res.GetResponseStream)

If not stmRdr.EndOfStream Then

  Do

    Console.WriteLine(stmRdr.ReadLine)

  Loop Until stmRdr.EndOfStream

End If

stmRdr.close()
res.Close()
req.Abort()


During
VB
req.GetResponse()
, I'm getting this error The underlying connection was closed: The server committed a protocol violation.

Any help is much appreciated.. Thanks.
Posted

1 solution

The problem is you've mixed FTP and SFTP which are completely different protocols. You can't connect to SSH/SFTP server using FTP client component.

.NET Framework doesn't have components for SSH and SFTP. You can check
 
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