C#读取XML中存在的账号密码登录系统
答案:1 悬赏:0
解决时间 2021-11-15 14:57
- 提问者网友:傀儡离开
- 2021-11-14 17:35
CS 系统 读取XML文件里的USER_NAME和USER_PASS 如果正确就登录系统 查询结果最好是bool型的 账号密码正确就返回true, 错误就返回false,求源代码,很急,万分感谢诸位大神
最佳答案
- 二级知识专家网友:丢不掉的轻狂
- 2021-11-14 18:50
//加载用户名及密码到Dictionary中
string[] strs = File.ReadAllLines("D:\\test.txt", Encoding.Default);
Dictionary UserPwd = new Dictionary();
foreach (string str in strs)
{
UserPwd.Add(str.Split(' ')[0].ToString(), str.Split(' ')[1].ToString());
}
//处理
string user = comboBox1.Text.ToString();
string pwd = textBox1.Text.Trim();
if (UserPwd.ContainsKey(user) && UserPwd[user] == pwd)
MessageBox.Show("True,Login In……");
else
MessageBox.Show("False,Can not Login……");
string[] strs = File.ReadAllLines("D:\\test.txt", Encoding.Default);
Dictionary
foreach (string str in strs)
{
UserPwd.Add(str.Split(' ')[0].ToString(), str.Split(' ')[1].ToString());
}
//处理
string user = comboBox1.Text.ToString();
string pwd = textBox1.Text.Trim();
if (UserPwd.ContainsKey(user) && UserPwd[user] == pwd)
MessageBox.Show("True,Login In……");
else
MessageBox.Show("False,Can not Login……");
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯