Ftp Connection Failure in VB.NET
Using the code below, I continue to get a "Unable to connect to the remote server" error at Using response as..
. I'm not quite sure whats wrong or where to look for help. FTP in .NET seems to be seldom used.
Ok, second stupid question. EnableSsl != Sftp?
Dim FTPrequest As FtpWebRequest = DirectCast(FtpWebRequest.Create(New Uri("ftp://176.31.212.85/dev/shm/Minecraft/world/players/Drise.dat")), FtpWebRequest)
FTPrequest.EnableSsl = True
FTPrequest.Credentials = New System.Net.NetworkCredential("user", "pass")
FTPrequest.Method = Ftp.DownloadFile
FTPrequest.UseBinary = True
FTPrequest.KeepAlive = False
Dim ftpstream As IO.Stream = Nothing
Using response As System.Net.FtpWebResponse = CType(FTPrequest.GetResponse(), System.Net.FtpWebResponse)
Using responseStream As IO.Stream = response.GetResponseStream
'loop to read & write to stream
Dim buffer(2047) As Byte
Dim read As Integer = 0
Do
开发者_运维技巧 read = responseStream.Read(buffer, 0, buffer.Length)
ftpstream.Write(buffer, 0, read)
Loop Until read = 0 'see Note(1)
responseStream.Close()
End Using
response.Close()
End Using
I'd like to provide some clarification I found later in regards to this question that I never got to posting. SFTP is part of the SSH family, not, SSL. VB.Net (since the last time I used it) does not support SFTP connections. There are some external libraries that do, but all of the ones I found required money.
精彩评论