I currently have a .TXT file and I'm trying to read all the lines, and sort them, and then display them in order.
Here is what I have
                string inFile = "Z:/Daniel/Accounts.txt";
                string outFile = "Z:/Daniel/SortedAccounts.txt";
                var contents = File.ReadAllLines(inFile);
                Array.Sort(contents);
                File.WriteAllLines(outFile, contents);
                int i = 0;
                int lineCount = File.ReadLines("Z:/Daniel/SortedAccounts.txt").Count();
                do
                {
                    string accounts = File.ReadLines("Z:/Daniel/SortedAccounts.txt").Skip(i).Take(1).First();
                    //First Name
                    int pFrom1 = accounts.IndexOf("#1#") + "#1#".Length;
                    int pTo1 = accounts.LastIndexOf("#2#");
                    String accountFirstName = accounts.Substring(pFrom1, pTo1 - pFrom1);
                    //Last Name
                    int pFrom2 = accounts.IndexOf("#2#") + "#2#".Length;
                    int pTo2 = accounts.LastIndexOf("#3#");
                    String accountLastName = accounts.Substring(pFrom2, pTo2 - pFrom2);
                    //Email
                    int pFrom3 = accounts.IndexOf("#3#") + "#3#".Length;
                    int pTo3 = accounts.LastIndexOf("#4#");
                    String accountEmail = accounts.Substring(pFrom3, pTo3 - pFrom3);
                    //Phone Number
                    int pFrom4 = accounts.IndexOf("#4#") + "#4#".Length;
                    int pTo4 = accounts.LastIndexOf("#5#");
                    String accountNumber = accounts.Substring(pFrom4, pTo4 - pFrom4);
                    //Preferred Contact
                    int pFrom5 = accounts.IndexOf("#5#") + "#5#".Length;
                    int pTo5 = accounts.LastIndexOf("#6#");
                    String accountPreferredContact = accounts.Substring(pFrom5, pTo5 - pFrom5);
                    //Populate Combobox
                    accountComboBox.Items.Add(accountLastName + "," + accountFirstName);
                    i = i + 1;
                } while (i < lineCount);
And an example of what's inside Accounts.txt is 
#1#Daniel#2#Mos#3#dasdnmasdda@gmail.com#4#31012304#5#EMAIL#6# #1#Daniael#2#Mosa#3#dddasdsa@gmail.com#4#310512304#5#EMAIL#6# #1#Dansdael#2#Mossdsa#3#dasdsdssa@gmail.com#4#31121234#5#TEXT#6# #1#Danasdl#2#Mosasaa#3#daasda@gmail.com#4#310123304#5#EMAIL#6# #1#Dandasel#2#Moasddand#3#daasdsda@gmail.com#4#3123551234#5#TEXT#6# #1#Danasdl#2#Mossdsadd#3#daasddsa@gmail.com#4#310213304#5#TEXT#6#
The issue is that sometimes, Accounts.txt will have over 10,000 lines and it then takes a while for the program to load.
Is there a faster implementation of the code I have written?
 
     
    