//讀取文字檔-所有行數以陣列方式
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");
}
文章標籤
全站熱搜
創作者介紹
創作者 ponchi961 的頭像
ponchi961

Nick Su 的部落格

ponchi961 發表在 痞客邦 留言(0) 人氣(2,951)