I have an embedded text file as a Resource. The content is:
Apple
Pear
Orange
I am trying to pull this into a List(Of String) but the Carriage Return and Line Feed characters are messing it up.
For example I try this:
Dim myNames As List(Of String) = My.Resources.TreeNames.Split(CChar(vbCrLf)).ToList
But the line feed character is being passed through:
"Apple"
vbLf & "Pear"
vbLf & "Orange"
so I try it using the environment variable:
Dim myNames As List(Of String) = My.Resources.TreeNames.Split(CChar(Environment.NewLine)).ToList
But that results in the exact same output.
So I try splitting it on the line feed character:
Dim myNames As List(Of String) = My.Resources.TreeNames.Split(CChar(vbLf)).ToList
And now the carriage return character is being passed through:
"Apple" & vbCr
"Pear" & vbCr
"Orange"
So the only way I got this to work is by first replacing the vbCr with nothing then splitting on the left over vbLf:
Dim myNames As List(Of String) = Replace(My.Resources.TreeNames, vbCr, "").Split(CChar(vbLf)).ToList
Can anyone explain why? If I pull the file in directly to a string using this:
Dim myNames as String = My.Resources.TreeNames
I get:
"Apple" & vbCrLf & "Pear" & vbCrLf & "Orange"
Why is split not working properly?