I'm parsing in a flat file by looping through and reading lines with a Streamreader.
Everything works well but a requirement changed where the field at the end of each record became optional. We validate the length of each line against the definition to determine if we should suspend that file as incorrectly formatted.
This lead to the discovery that Streamreader.ReadLine will trim any trailing spaces after the last character and before the newline.
Consider the following example with the numbers replaced by spaces:
BOB JONES 12345\n BOB JONES \n
The streamreader will, with both ReadLine and ReadToEnd store ignore those spaces. Here is the result in memory:
Readline:
"BOB JONES 12345" "BOB JONES"
ReadToEnd:
"BOB JONES 12345" & vbrclf & "Bob Jones"
Same deal with Readblock and then copying the buffer results into a string.
I will take a different approach to validating the length of the record since the ending date field is optional, but my question is why is the Streamreader dropping those ending spaces? And how would I read them in if I needed to?