//讀取文字檔-所有行數以陣列方式
string[] lines = System.IO.File.ReadAllLines(@"C:\Log.txt", Encoding.Default);
//讀取文字檔-將文字檔內容組成string
string text = System.IO.File.ReadAllText(@"C:\Log.txt", Encoding.Default);
//寫入文字檔-參數分別為檔名、是否覆蓋原本檔案(true = no,false = yes)、文字編碼
using (System.IO.StreamWriter file = new System.IO.StreamWriter((@"C:\Log.txt", false, Encoding.Default))
{
file.WriteLine("TEST");
}
文章標籤
全站熱搜
