I have twenty 10MB txt files and would like to read these files.
I have read this, which says File.ReadLines()
doesn't load entire lines so it doesn't spend much memory.
var directory = "path/to/files";
foreach (var filepath in Directory.EnumerateFiles(directory, "*.txt"))
{
foreach (var line in File.ReadLines(filepath))
{
// I will do something here, but not yet.
}
}
But when I run this code, Jetbrains Rider DPA says like below image.
How can I fix this problem?
Environment: .NET Core Console Application (6.0)
Edit
Same problem with StreamReader
.