Link to home
Start Free TrialLog in
Avatar of Frans_Truyens
Frans_TruyensFlag for Belgium

asked on

ReadAllText and reading a textfile into a string

I want to read a textfile into a string. The problem is that I need a CrLf character at the end of each line.
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

It is supposed to be already there if it is in your source file.
Avatar of Frans_Truyens

ASKER

I read a large file, >150 Mega, with ReadAllText. This file is a .txt file, with linebreaks. Then  I am using Regex to find the lines that start with STOP. There are multiple lines that start with STOP. But it will only find the first one. It is not an error of Regex, but just, the result is only one line.
I know I can use a StreamReader, but that is rather slow. I want ReadAllText, but that it keeps the linebreakw. StreamReader is just too slow;
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am searching those files.
It has to do with the end of line characters. Or I presume that that is the problem. Because if I look for a string inside the file, on any position, it works. Only if I am looking for leading strings, I have that problem
I found it myself. It is required to use the option 'multiline', and then it works. Thanks for your time.
On which object that multiline option?