//记录日志
public void RecordLog(string content)
{
string logSite = AppDomain.CurrentDomain.BaseDirectory + "log.txt";//本地文件
if (!File.Exists(logSite)) File.Create(logSite);
//历史记录读取
List<string> historyRecord = new List<string>();
StreamReader sr = new StreamReader(logSite, false);
string readLine;
while (!string.IsNullOrEmpty(readLine = sr.ReadLine()))
{
historyRecord.Add(readLine);
}
sr.Close();
sr.Dispose();
historyRecord.Add(content);
//新纪录存储
StreamWriter sw = new StreamWriter(logSite, false);
for (int i = 0; i < historyRecord.Count; i++)
{
sw.WriteLine(historyRecord[i]);
}
sw.Close();
sw.Dispose();
}