I have created a GUI (Windows Form) that has FileBrowserdialogs in which you can choose the folder and display the contents on each listbox respectively. However, I want to compare both list boxes and display the differences in the strings on the third list box by pressing a button. For example:
Usually, the string will have changes in the highlighted area but the unhighlighted area will have the same text for each item. I am new to C# so any
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
FolderBrowserDialog FBD = new FolderBrowserDialog();
if (FBD.ShowDialog()
== DialogResult.OK)
{
listBox1.Items.Clear();
string[] files
= Directory.GetFiles(FBD.SelectedPath);
string[] dirs
= Directory.GetDirectories(FBD.SelectedPath);
foreach (string file in files)
{
listBox1.Items.Add(file);
}
foreach (string dir in dirs)
{
listBox1.Items.Add(dir);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
FolderBrowserDialog FBD = new FolderBrowserDialog();
if (FBD.ShowDialog()
== DialogResult.OK)
{
listBox2.Items.Clear();
string[] files
= Directory.GetFiles(FBD.SelectedPath);
string[] dirs
= Directory.GetDirectories(FBD.SelectedPath);
foreach (string file in files)
{
listBox2.Items.Add(file);
}
foreach (string dir in dirs)
{
listBox2.Items.Add(dir);
}
}
{
}
}
private void button3_Click(object sender, EventArgs e)
{
}
}
}