using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; namespace CompareLoadOrder { class Program { static void Main(string[] args) { //get a buffer to return to zero Stream s = new MemoryStream(); //our three files. StreamReader alpha= new StreamReader(@"alpha.txt"); StreamReader beta= new StreamReader(@"beta.txt"); StreamWriter output = new StreamWriter(@"output.txt"); //internal listing so we can mess with data List alphaList = new List(); List betaList = new List(); List outputList = new List(); //fill alphaList for (int i = 0; i < File.ReadLines(@"alpha.txt").Count(); i++) { string newData = alpha.ReadLine(); alphaList.Add(newData); } //fill betaList for (int i = 0; i < File.ReadLines(@"beta.txt").Count(); i++) { string newData = beta.ReadLine(); betaList.Add(newData); } //return the readers back to index 0, start of file s.Position = 0; alpha.DiscardBufferedData(); beta.DiscardBufferedData(); //compare the two files. If any matches 100%, save the match to outputList for (int i = 0; i < File.ReadLines(@"alpha.txt").Count(); i++) { for (int j = 0; j < File.ReadLines(@"beta.txt").Count(); j++) { if (alphaList[i].Equals(betaList[j])) { outputList.Add(alphaList[i]); } } } //write the outputList to a new file. for (int i = 0; i < outputList.Count(); i++) { output.WriteLine(outputList[i]); } } } }