/// <summary>
/// 读取txt文件
/// </summary>
/// <param name="path"></param>
public static string Read(string path)
{
StreamReader sr = new StreamReader(path, Encoding.Default);
return sr.ReadLine();
}
/// <summary>
/// 写入txt文件
/// </summary>
/// <param name="path"></param>
public static Boolean Write(string path,string str)
{
try
{
FileStream fs = new FileStream(path, FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
//开始写入
sw.Write(str);
//清空缓冲区
sw.Flush();
//关闭流
sw.Close();
fs.Close();
return true;
}
catch(Exception ex)
{
return false;
}
}