I am developing a component that will download a file from our FTP
server and it is working. I am curious as to how I can make the FTP
session secure. I've seen a lot of components for sale but I don't
think that is necessary if I can accomplish this with a few more lines
of code. Here is my vb I'm using:
If (RTrim(Me.Filename.Text.ToString) <"") Then
sFileName = Me.Filename.Text
'MsgBox("Get File: " & sFileName)
Dim uri As New Uri("ftp://ftp.myserver.com/" & sFileName)
If (uri.Scheme = uri.UriSchemeFtp) Then
Dim request As FtpWebRequest =
FtpWebRequest.Create(uri)
request.Credentials = New NetworkCredential("username",
"password")
request.UseBinary = True
request.Method = WebRequestMethods.Ftp.DownloadFile
Dim Response = request.GetResponse()
Dim responseStream As IO.Stream =
Response.GetResponseStream()
Dim fs As New IO.FileStream("c:\" & sFileName,
FileMode.Create)
Dim buffer(2047) As Byte
Dim read As Int32 = 0
Do
read = responseStream.Read(buffer, 0,
buffer.Length)
fs.Write(buffer, 0, read)
Loop Until read = 0
fs.Flush()
fs.Close()
responseStream.Close()
Response.Close()
End If
Else
MsgBox("Please enter a file name to download")
End If
As I said this code is working perfectly, I just need to know how to
make my ftp session secure. Thanks for any help.