⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 log.cs

📁 gps
💻 CS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -