Лука Поповић Лука Поповић - 3 years ago 90
Vb.net Question

StreamReader: Why reading all text in one line?

i need little help.
First sorry for my terrible English.
So, im working on my project coded in .net, im using Visual Studio 2015.
I trying to get raw text from url to textbox.
When i say raw i mean https://example.com/files/SomeText.txt

So what i want is to get txt to my textbox like this (Same what i see in browser)

information11 data1 number1
information11 data1 number1
information11 data1 number1
information11 data1 number1


but it appears like this

information11 data1 number1 information11 data1 number1 information11 data1 number1 information11 data1 number1


Here is my code

Dim adrs As String = "https://example.com/files/SomeText.txt"
Dim client As WebClient = New WebClient()
Dim reader As StreamReader = New StreamReader(client.OpenRead(adrs))
TextBox1.Text = reader.ReadToEnd

Answer Source

Please try checking the string you receive in a text editor that will show hidden characters, like Word or Notepad++. You may be getting a line feed character that should instead be a Carriage-Return Line Feed. If that is the case you can convert it like this.

Dim text As String = reader.ReadToEnd
TextBox1.Text = text.Replace(vbLF, vbCrLf)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download