I am writing a code that allows a user to brows a text file and then check if the content in that text file appears in another text file.
Currently I have this code.
DialogResult result = openFileDialog1.Show()
If (result == DialogResult.OK)
{
string file = openFileDialog1.FileName;
try
{
StreamReader sr = new StreamReader(FilePath);
String Data = sr.ReadToEnd();
sr.Close();
string text = File.ReadAllText(file);
If (Data == text)
{
MessageBox.Show("This files are the same", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("This files are not the same", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (IOException ie)
{
MessageBox.Show(ie.ToString(), "Exception Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
This can only check if the text files are the same but i also want to check if the content in the text file the user browses for appear in the text file I read in my streamRead, how can I do that?