📄 userlogin.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace RFID_CAR
{
class UserLogin
{
public const string gc_str_files_path = "\\My Documents";
private const char m_c_field_separator = ',';
public static string get_user_info_file_path()
{
return gc_str_files_path + "\\User.txt";
}
public string[] get_users()
{
string[] users = new string [256];
int i = 0;
try
{
using (StreamReader stream = File.OpenText(get_user_info_file_path()))
{
while (stream.Peek() >= 0)
{
string str = stream.ReadLine();
string[] pstr_fields = str.Split(m_c_field_separator);
users[i] = pstr_fields[2];
i++;
}
stream.Close();
}
}
catch (Exception e_valid)
{
System.Windows.Forms.MessageBox.Show("err_valid:" + e_valid.Message);
}
return users;
}
public bool is_valid_user_login(string str_id, string str_pw)
{
bool br = false;
try
{
using (StreamReader stream = File.OpenText(get_user_info_file_path()))
{
while (stream.Peek() >= 0)
{
string str = stream.ReadLine();
string[] pstr_fields = str.Split(m_c_field_separator);
if (0 == str_id.CompareTo(pstr_fields[2]) && 0 == str_pw.CompareTo(pstr_fields[1]))
{
br = true;
break;
}
}
stream.Close();
}
}
catch (Exception e_valid)
{
System.Windows.Forms.MessageBox.Show("err_valid:" + e_valid.Message);
}
return br;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -