http://blogs.msdn.com/adarshk/archive/2005/04/22/410925.aspx
After an effort of 2-3 days, however, I came to know that the .NET framework 2.0 till now supports only EXPLICIT FTP over SSL and not Implicit connection (which is usually established above port 990)
http://www.developmentnow.com/g/46_2006_5_0_0_755554/implicit-ftp--SSL-problem.htm
Turned out I could not do this without an external component involved. I tested the component available here and was able to connect to my FTP and didnt even require to verify the client certificate:
http://www.rebex.net/download/GetFileNotify.aspx?f=RebexTotalPack-Trial-1.0.3428.0-DotNet2.0.exe
A sample code of the function I used is:
Public Function GetFileByRebex()
Dim ftp As New Ftp()
ftp.Connect(ConfigurationManager.AppSettings("FTPUrl").ToString(), 990, Nothing, FtpSecurity.Implicit)
ftp.Login(ConfigurationManager.AppSettings("FTPUser"), ConfigurationManager.AppSettings("FTPPw"))
ftp.ChangeDirectory(ConfigurationManager.AppSettings("FTPWorkingDir"))
Dim fileNames As FtpList
fileNames = ftp.GetList()
Dim i As Integer
For i = 0 To (fileNames.Count - 1)
'Dim b As String
'b = fileNames.Item(i).Modified.Date.ToString()
If (fileNames.Item(i).Modified.Date.Equals(Today.Date)) Then
'Download file
todaysFileName = Now
todaysFileName = todaysFileName.Replace("/", "-")
todaysFileName = todaysFileName.Replace(":", "-")
ftp.GetFile(fileNames.Item(i).Name, Server.MapPath(ConfigurationManager.AppSettings("DownloadFolderName")) + todaysFileName + ".csv")
Exit For
End If
Next
End Function
No comments:
Post a Comment