userlogin.cs
来自「手持式RFID及条码车辆识别系统手持机代码」· CS 代码 · 共 70 行
CS
70 行
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 + =
减小字号Ctrl + -
显示快捷键?