-2

I have declared a string that holds all the current settings of a device string settings = "". I want to compare that to another string which holds the correct settings for that device which is saved in a text file. If both strings are equal then I know no changes need to be made to the settings as they are correct.
The .PFL file is in a dropdown menu of other settings. So I have the string of the settings file and want to compare that to the string on the .PFL file.
I have a snippet of the code I have done so far, think I'm on the right track. If i declared another string it would be simple to compare but how would I compare from a string on a text file.

private void button1_Click(object sender, EventArgs e)
{
    Cancel = false;
    string Settings = "S0=80,S1=01,S2=7F2037,S3=44,S4=081E,S5=8832,S6=8846,S7=00,S8=00,SS15=84.51.244.10,S16=9000,S17=0049351928,S18=500,S19=0000,S20=00,S21=,S22=,S23=13,S24=00,S25=00,S26=00,S27=19";

    UpdateConsole(Settings + "\r\n");
    string c = Settings.Trim();
    if(c==d)
    {
        UpdateConsole("Pass Settings are equal");
    }
}
Christoph Fink
  • 22,727
  • 9
  • 68
  • 113
tester123
  • 399
  • 1
  • 3
  • 10

1 Answers1

0

You can use File.ReadAllText(<pathoffile>) to read the file into a string, and compare that to your other string.

Øyvind Bråthen
  • 59,338
  • 27
  • 124
  • 151