log.cs
来自「gps」· CS 代码 · 共 56 行
CS
56 行
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace GPSClassLibrary
{
public class Log
{
string logPath;
public bool IsValid = false;
public Log(string path)
{
if (path != "")
{
logPath = path + ".log";
if (!File.Exists(logPath))
File.Create(logPath);
IsValid = true;
}
}
public void writeLog(string strWrite)
{
using (StreamWriter sw = new StreamWriter(logPath, true))
{
sw.WriteLine(strWrite);
sw.Close();
}
}
public string[] ReadLog()
{
List<string> strList = new List<string>();
using (StreamReader sr = new StreamReader(logPath))
{
if (sr != StreamReader.Null)
{
while (!sr.EndOfStream)
{
strList.Add(sr.ReadLine());
}
}
sr.Close();
}
return strList.ToArray();
}
public void ClearLog()
{
using (StreamWriter sw = new StreamWriter(logPath,false))
{
sw.Write("");
sw.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?