Quick-read question: I was wondering if there'd be other techniques that I overlooked, maybe p/invoke to a certain library (be it winapi or third party library). All advice is welcome.
The full context of the question: For a given usecase I need to read textfiles into memory which I afterwards can manipulate. The problem lies not in the manipulation though but in the I/O. I'm currently using following techniques withing C#:
1) ReadAllText() method of "File"
var content = File.ReadAllText(file.FullName);
2) ReadToEnd() method of "StreamReader"
var content = String.Empty;
using(var streamReader = File.OpenText(file.FullName)) {
content = streamReader.ReadToEnd();
}
3) I also tried using a BufferedStream
in conjunction with method 2
All had roughly the same performance for files between 5 to 20MB. So, here comes the question then: I was wondering if there'd be other techniques that I overlooked, maybe p/invoke to a certain library (be it winapi or third party library). All advice is welcome.