I have a file and I need to read it line after line.
Each line ends with “###” and not with the regular end-of-line character (\n).
Is there any way to change the streamReader so when I use the ReadLine() it will read until it sees “###”?
If not, is there another way to do it or should I implement a new class for this purpose?
No, you cannot do this with
StreamReader. The StreamReader class is hardcoded to recognize\rand\ncharacters and it is not configurable. You can see this using .NET Reflector:If your files are not too large you can instead read the entire file into memory and then split on
###. If you need the streaming behaviour then you could write something similar toReadLineyourself, but with the behaviour you desire.