shandoosheri
shandoosheri

Reputation: 3

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

Upvotes: 0

Views: 2221

Answers (2)

Stephan
Stephan

Reputation: 4247

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!");
}

Upvotes: 2

m.edmondson
m.edmondson

Reputation: 30922

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

Upvotes: 0

Related Questions