> FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpaddress); > //List all the files in the directory > request.Method = WebRequestMethods.Ftp.ListDirectoryDetails; >>
' FTP setup loFtpWebRequest = System.Net.FtpWebRequest.Create(New Uri(lcURI)) loFtpWebRequest.Credentials = New System.Net.NetworkCredential(cUsername, cPassword) loFtpWebRequest.Method = System.Net.WebRequestMethods.Ftp.ListDirectoryDetails loFtpWebRequest.KeepAlive = False ' If we use FTP/SSL (AUTH SSL) If nNoFTPProtocol = 2 Then loFtpWebRequest.EnableSsl = True End If Using loFtpWebResponse As System.Net.FtpWebResponse = loFtpWebRequest.GetResponse() Using loStream As System.IO.Stream = loFtpWebResponse.GetResponseStream() Using loStreamReader As New StreamReader(loStream) ' Load the files into the string builder loStringBuilder.LoadString(loStreamReader.ReadToEnd()) End Using End Using End Using ' Initialization cDirectoryContentFromFTP = loStringBuilder.oStringBuilder.ToString ' For each file For lnCounter2 = 1 To loStringBuilder.nLineSo, basically, it is the same start as you. Then, I stream and put each line into a collection.