Read textfile. Carriage Return Characters.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a text file which has a Carriage Return Character in the middle of the
line. When I open the file in notepad the character is shown as a box whereas
in word it acts as a carriage return.

When I read the file using either LineInput Method of the
Microsoft.VisualBasic.FileSystem Module or the ReadLine Method of the
StreamReader class only the part before the Carriage Return Character is
returned and the next part is returned with a subsequent call. Is it possible
to return the full line with one call.

Regards - Nathan
 
You can reformat your string, and remove those carriage return symbols in
the middle.

ReadLine method detects the end of line with the help of that symbol...

Another way is that you can introduce your own delimeters, and then work
with them.
 
Thanks, But I have no control how the file is written. The files i am reading
are TAB delimeted files with thousands of lines which I am reading OK until I
hit the rogue line. I don't know what the difference between this character
that works as a carriage return in Word but shows as box in Notepad & a
carriage retutrn that works in both Word & Notepad is.

Regards - Nathan
 
Nathan Taylor said:
Thanks, But I have no control how the file is written. The files i am reading
are TAB delimeted files with thousands of lines which I am reading OK until I
hit the rogue line. I don't know what the difference between this character
that works as a carriage return in Word but shows as box in Notepad & a
carriage retutrn that works in both Word & Notepad is.

The difference is that notepad is looking for carriage-return line-
feed, not just carriage-return.

You'll have trouble reading that file line by line and treating it as a
whole line though. You *could* read the whole file in, replace "\r\n"
with "\n" and then the remaining "\r" with "", but that would be pretty
inefficient...
 
Back
Top