Click here to Skip to main content
16,020,249 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am currently trying to get list of files in an FTP directory in .net and i am getting the following characters before the name of the files "./" & vbCr & "../" & vbCr & "

how do i get just the listing of the file names without these characters in front?

This is what is being returned after reading to end
"./" & vbCrLf & "../" & vbCrLf & "filename.xlsx" & vbCrLf & ""

What I have tried:

VB
Dim Request As FtpWebRequest
Dim Response As FtpWebResponse

Request = DirectCast(FtpWebRequest.Create(FtpFolderPath), FtpWebRequest)

Request.Credentials = New NetworkCredential(UserName.Normalize, Password.Normalize)
Request.Proxy = Nothing
Request.Method = WebRequestMethods.Ftp.ListDirectory
Request.UseBinary = True

Response = DirectCast(Request.GetResponse(), FtpWebResponse)
Dim reader As New StreamReader(Response.GetResponseStream())
Dim Data As String = reader.ReadToEnd()

Data = Data.Replace(vbCrLf, vbCr).TrimEnd(Chr(13))


reader.Close()
Response.Close()
Return Data.Split(ControlChars.Lf)
Posted
Updated 5-Jul-16 0:17am
v2

1 solution

Try:
C#
Dim Data As String = reader.ReadToEnd().Replace("./" & vbCrLf & "../" & vbCrLf, "")
 
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