Remove "invisible" control characters in VB.Net

I am currently reading a text file in VB.Net using

Dim fileReader As String
fileReader = My.Computer.FileSystem.ReadAllText(file)

The file contains several lines of text, and when I read in a text file, it knows that they are on separate lines and prints them accordingly.

However, when I try to split the Reader file into an array of different lines, the line break seems to remain there even if I use Split(ControlChars.Cr)or Split(ControlChars.NewLine). It will successfully split it into separate lines, but when I show it, it will “push” the text onto the line, as if the line break is still there ...

Does anyone have any ideas on what is going on and how I can remove these “invisible” control characters.

Text file:

Test1
Test2
Test3
Test4

FileReader:

Test1
Test2
Test3
Test4

()

Test1

Test2

Test3

Test4

+3
4

trim() , .

+4

System.IO.File ReadAllLines, , .

, , . System.Text.Encoding.ASCII.GetBytes(sampleLine) , .

, ASCII, , ASCII , , .

+2

, Readalllines, .

, , - ASCII, , , , , . , , , .

dim s() string = Split (fileReader, vbCrLf)

Trim , , .

+1

. Trim() , split ( File.ReadAllLines). , :

    Dim allText As String = System.IO.File.ReadAllText(filePath)
    allText = allText.Replace(Chr(13), "")
    Dim lines As String() = allText.Split(vbLf)

Chr (13) - Control-M, Split() File.ReadAllLines.

0

All Articles