简体   繁体   English

check.txt 文件内容是否与文本框中的文本匹配 c#

[英]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嗨,我需要验证一个文本框输入 throw a.dat file[plain text] 如果它匹配它做其他事情,如果不是我显示一个弹出消息,任何帮助将不胜感激,如果你也可以告诉我如何加密that.dat 文件更安全
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.看看StreamReader ,它将允许您将文件读入您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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