I am using VB.NET TextFieldParser (Microsoft.VisualBasic.FileIO.TextFieldParser) to read a delimited file. However, when I try to read in a field with consecutive news in a field, consecutive lines of a new line turn into one new line. I would like consecutive lines to be saved, but I'm not sure how to do this.
Here is an example file that I am reading with one field. The quotation marks are part of the contents of the file, and there are three newlines (including two consecutive newlines, following line 2):
"This is line 1 This is line 2 This is line 4, which follows two consecutive newlines."
Here is the code that I use to parse and read in a file:
Dim reader as New Microsoft.VisualBasic.FileIO.TextFieldParser(myFile, System.Text.Encoding.Default) reader.TextFieldType = FileIO.FieldType.Delimited reader.SetDelimiters(",") Dim fields As String() = reader.ReadFields Dim line As String = fields(0)
And here is the contents of the variable "string". Note that now there are only two lines:
This is line 1 This is line 2 This is line 4, which follows two consecutive newlines.
What can I do to save consecutive lines of a new line?
sparks
source share