filescontrol.cs
来自「手持式RFID及条码车辆识别系统手持机代码」· CS 代码 · 共 67 行
CS
67 行
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace RFID_CAR
{
class FilesControl
{
public const string gc_str_files_path = "\\My Documents";
private const char m_c_field_separator = ',';
public bool is_xcwj_txt()
{
return File.Exists(gc_str_files_path+"\\xcwj.txt");
}
public bool findin_xcwj_txt(string str_uid,ref string str_record)
{
bool ret_b = false;
string valid = "1";
try
{
using (StreamReader stream = File.OpenText(gc_str_files_path + "\\xcwj.txt"))
{
while (stream.Peek() >= 0)
{
string str = stream.ReadLine();
string[] pstr_fields = str.Split(m_c_field_separator);
if (string.Equals(pstr_fields[0], str_uid))
if (string.Equals(pstr_fields[2], valid ))
{
str_record = string.Copy(str);
ret_b = true;
break;
}
}
stream.Close();
}
}
catch (Exception e_valid)
{
System.Windows.Forms.MessageBox.Show("err_valid:" + e_valid.Message);
}
return ret_b;
}
public bool write_scwj_txt(string str_input)
{
if(!File.Exists(gc_str_files_path+"\\scwj.txt"))
File.CreateText(gc_str_files_path+"\\scwj.txt");
try
{
StreamWriter stream = File.AppendText(gc_str_files_path+"\\scwj.txt");
stream.WriteLine (str_input);
stream.Close();
}
catch(Exception e)
{
return false;
}
return true;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?