ReadFile - Unable to split resulting text file into separate lines
I have a file which looks like:
WASTEWATER;http://XXX1;LID
WASTEWATER;http://XXX2;LID,PROJECTNUMBER,WORKORDERID
WASTEWATER;http://XXX3;LID,PROJECTNUMBER,WORKORDERID
WASTEWATER;http://XXX4;LID
I am using ReadFile to get this from a virtual directory location and make a text string out of it. The problem is parsing this into lines.
1. Split entire string on Environment.Newline, then loop lines
2. First line split on ";" which should give me three values for the first line, WASTEWATER, https://XXX1, and LID
PROBLEM: What I am getting for the third value of the first line is 'LID WASTEWATER' - it is grabbing the last word at the end of the first line and the first workd on the second line.
There has to be a better way to do this - how do I read this file, line by line?
Thanks
Tami
0
-
Tami - Do you know the source OS of the data? Every OS uses a slightly different newline characters. '\r" vs "\n" vs "\r\n". The Environment.NewLine, assumming Windows OS, will be "\r\n" (e.g. CRLF) and it is probably only seeing a \r or \n but not \r\n, thus the wrapping. I would open your source file with something like Notepad++ and turn on all characters to inspect exactly how this file is being written to determine the newline characters being used first. 0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
1 kommentar