So I have 5 textfiles that are 50GB each and I'd like to combine all of them into 1 textfile and then call the LINQ statement .Distinct()
so that there are only unique entries in the new file.
The way I'm doing it now is like so
foreach (var file in files)
{
if (Path.GetExtension(file) == ".txt")
{
var lines = File.ReadAllLines(file);
var b = lines.Distinct();
File.AppendAllLines(clear, lines);
}
}
The issue that occurs here is that the application now loads the entire textfile into memory, making my RAM usage go up to 100%. This solution might of worked if I had 64GB of ram but I only have 16GB. What's the best option for me to achieve what I'm trying to accomplish? Should I utilize the cores on my CPU? Running a 5900x.