Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I'm trying to get all the files inside a folder from a FTP Server
I found a code for doing this in Internet

Dim reqFTP As FtpWebRequest = Nothing
reqFTP = DirectCast(WebRequest.Create("ftp://ftp.microsoft.com/Products/mediaplayer/MACOS/"), FtpWebRequest)
reqFTP.Method = WebRequestMethods.Ftp.ListDirectoryDetails
reqFTP.Credentials = New NetworkCredential(UserID, Password)
response = DirectCast(reqFTP.GetResponse(), FtpWebResponse)
Dim responseStream As Stream = response.GetResponseStream()
Dim reader As New StreamReader(responseStream)
Console.WriteLine(reader.ReadToEnd())


Result in Console.WriteLine is
09-28-98  04:51PM              3149614 MacOSPlayer3.1b1c7.hqx
09-17-98  09:43AM                 6035 MacReadMe.txt



my problem is when I'm using the reader.ReadToEnd()
and put it in a ListBox, the result is just one line.

09-28-98  04:51PM              3149614 MacOSPlayer3.1b1c7.hqx**09-17-98  09:43AM                 6035 MacReadMe.txt**

* is a character i don't know what it is, its kinda a rectangle type character


How can I put the result in a ListBox but the result is the same with the Console.
Any suggestion is appreciated

Thanks....
Posted
Updated 2-Jun-11 0:50am
v4

1 solution

reader.ReadToEnd returns a string. So this is one result displayed as one line. Use string.split to split the lines.

Dim Lf As Char = ToChar(CByte(10))
Dim Cr As Char = ToChar(CByte(13))
Dim CrLf As Char() = {Cr, Lf}

Dim lines() as string = reader.ReadToEnd().Split(CrLf, StringSplitOptions.RemoveEmptyEntries)


The ** are the cariage return linefeed (CrLf) characters.
 
Share this answer
 
v2
Comments
hansoctantan 2-Jun-11 7:04am    
thank you very much, code has run

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