Issue in splitting an array of strings

vb.net, visual-studio-2010

Solution

You are not splitting by `NewLine` since you are cutting off `Environment.NewLine` which is a `string` with `CChar`. You just have to use the overload of `String.Split` that takes a `String()` and a `StringSplitOption`:

So instead of

Dim text = sr2.ReadToEnd()
Dim datastring() As String = text.Split(CChar(Environment.NewLine))

this

Dim datastring() As String = text.Split({Environment.NewLine}, StringSplitOptions.None)

Problem

I'm using webrequests to retrieve data in a .txt file that's on my dropbox using this "format". ``` SomeStuff AnotherStuff StillAnother ``` And i'm using this code to retrieve each line and read it: ``` Private Sub DataCheck() Dim datarequest As HttpWebRequest = CType(HttpWebRequest.Create("https://dl.dropboxusercontent.com.txt"), HttpWebRequest) Dim dataresponse As HttpWebResponse = CType(datarequest.GetResponse(), HttpWebResponse) Dim sr2 As System.IO.StreamReader = New System.IO.StreamReader(dataresponse.GetResponseStream()) Dim datastring() As String = sr2.ReadToEnd().Split(CChar(Environment.NewLine)) If datastring(datastring.Length - 1) <> String.Empty Then For Each individualdata In datastring MessageBox.Show(individualdata) Console.WriteLine(individualdata) Next End If End Sub ``` The problem is, the output is this: It always adds a line break (equal to " " as i see as first character on each but the first line string) after the first line like: http://img203.imageshack.us/img203/1296/gejb.png Why this happens? I tried also replacing the Environment.Newline with nothing like this: ``` Dim newstring as String = individualdata.Replace(Environment.Newline, String.Empty) ``` But the result was the same... what's the problem here? I tried with multiple newline strings and consts like vbnewline, all had the same result, any ideas?

Original source