C# matching two text files, case sensitive issue

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-04-28T17:53:00Z Indexed on 2010/04/28 17:57 UTC
Read the original article Hit count: 127

Filed under:

What i have is two files, sourcecolumns.txt and destcolumns.txt. What i need to do is compare source to dest and if the text doesnt match write out to a new file. The code below works except i have case sensitive issues like this:

CPI
Cpi

These say they dont match because of captial letters, any help is always thanked!

string[] sourcelinestotal = File.ReadAllLines(@"C:\testdirectory\"          + "sourcecolumns.txt");
        string[] destlinestotal = File.ReadAllLines(@"C:\testdirectory\" + "destcolumns.txt");
        foreach (string sline in sourcelinestotal)
        {
            if(destlinestotal.Contains(sline))
            {

            }
            else
            {
                File.AppendAllText(@"C:\testdirectory\" + "missingcolumns.txt", sline);
            }
        }

© Stack Overflow or respective owner

Related posts about c#