简体   繁体   中英

check .txt file content if it match the text in the text box c#

Hi i need to validate a text-box input throw a.dat file[plain text] if it matches it do other stuff and if not i displays a pop up message any help would be appreciated and if you can also tell me how to encrypt that.dat file to more secure
Thank you

Try something like this:

// read file content into a string
String fileContent = System.IO.File.ReadAllText(@"c:\file.dat");

// compare TextBox content with file content
if (fileContent.Equals(myTextBox.Text))
{
    // do something
}
else
{
    MessageBox.Show("Error!");
}

Take a look at StreamReader , that will allow you to read the file into your app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM