I have more than 20 files, each of them contain almost 1 million lines (5 Gigabyte), I need to speed up the reading process, so I'm trying to read those files in parallel, but it takes longer time than reading them sequentially. is there any way to read a very large files in parallel?
Parallel.ForEach(sourceFilesList, filePath =>
{
if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))
{
StreamReader str = new StreamReader(filePath);
while (!str.EndOfStream)
{
var temporaryObj = new object();
string line = str.ReadLine();
// process line here
}
}
});