首先我制作了textbox1(用于用户名)、textbox2(用于密码)和button1(检查)。
后:
private void button1_Click(object sender, EventArgs e)
{
FileStream fs = new FileStream(@"D:\C#\test.txt", FileMode.Open, FileAccess.Read, FileShare.None);
StreamReader sr = new StreamReader(fs);
}
我想检查 test.txt 第一行的用户名(相当于在 textbox1 中添加我的文本)和第二行的密码。
对不起,我的英语不好。
你可以尝试这样的事情:
private void button1_Click(object sender, EventArgs e){
string[] lines = System.IO.File.ReadAllLines(@"D:\C#\test.txt");
String username = lines[0];
String password = lines[1];
}
但是,这并不是存储用户名和密码的好方法。我假设你只是在测试一些东西。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)