0

I have a WPF application with a csv file that gets displayed in a texbox when the application is loaded, like so:

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            path = @"C:\Users\user\Documents\app\mainFile.csv";

            mainFile = File.ReadAllText(path);

            txtDisplay.Text = mainFile;
        }

Also, I have 2 buttons: Upload and Compare. The upload button has the following code:

        private void btnUpload_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            if(openFileDialog.ShowDialog() == true)
            {
                compareFile = File.ReadAllText(openFileDialog.FileName);
                MessageBox.Show("File Uploaded");
            }
        }

Once a file is uploaded it gets stored in the compareFile variable. What I want to do is, once the compare button is clicked, the 2 files (mainFile and compareFile) to be compared and output the non-matching lines into another CSV file. I was hoping someone could point me in the right direction to solving this, I have little to no programming experience, so any help is appreciated.

Here are the CSV files just in case you needed to see the format:

compareFile

id,firstname,lastname,email,city
10,Jaime,Odell,[email protected],Lagos
11,Charlena,Birdella,[email protected],Liverpool
12,Kristan,Phaidra,[email protected],Innsbruck
13,Annecorinne,Lay,[email protected],San Juan
14,Dotty,Sidonius,[email protected],Curitiba
15,Mellicent,Maurine,[email protected],Rio de Janeiro
16,Bill,Khorma,[email protected],Dongguan
17,Kary,Nicoline,[email protected],Zagreb
18,Karena,Martguerita,[email protected],Mexico City
19,Antonietta,Thunell,[email protected],Kandy

mainFile

id,firstname,lastname,email,city
10,Jaime,Odell,[email protected],Lagos
11,Charlena,Birdella,[email protected],Liverpool
12,Kristan,Phaidra,[email protected],Innsbruck
13,Keelia,Callista,[email protected],Gibraltar
14,Binny,Boycey,[email protected],Adelaide
15,Therine,Euridice,[email protected],Shenyang
16,Belinda,Olympium,[email protected],Maseru
17,Kary,Nicoline,[email protected],Zagreb
18,Karena,Martguerita,[email protected],Mexico City
19,Antonietta,Thunell,[email protected],Kandy
3
  • does it help? stackoverflow.com/questions/46688563/… Commented Nov 26, 2021 at 18:02
  • Looks like what I need, but I am unable to install it on visual studio, says: Package does not contain any assembly references or content files that are compatible with that framework. What version of .NET do i need? Commented Nov 26, 2021 at 18:46
  • 1
    .net framework 4.5+, .net core 2.x, .net standard Commented Nov 26, 2021 at 19:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.