[心得] 寫一個簡單Debug 日誌檔
底下C#程式,是一個簡單記錄LOG的日誌檔方式:
using System;
using System.IO;//FileStream, Stream Writer and Reader 的 namespace
class MainClass
{
public static void Main()
{
string logFile = "LOGFILE.TXT";//Debug log 檔案名稱
FileStream fs = new FileStream(logFile, FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs); //寫檔
StreamReader sr = new StreamReader(fs); //讀檔
sw.WriteLine("AAA");
sw.WriteLine("BBB");
while(sr.Peek() > -1)//將全部檔案資料讀出
{
Console.WriteLine(sr.ReadLine());
}
sw.Close();
sr.Close();
fs.Close();
}
}
詳細內容請至:http://tw-hkt.blogspot.com/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.59.0.57
→
05/28 18:15, , 1F
05/28 18:15, 1F
推
05/28 20:59, , 2F
05/28 20:59, 2F
推
05/28 21:02, , 3F
05/28 21:02, 3F
推
05/29 03:56, , 4F
05/29 03:56, 4F
推
05/31 22:47, , 5F
05/31 22:47, 5F