星期二, 3月 30, 2010

Save & Read File (txt)


string dir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); //系統路徑
string path = dir + "\\autoPlan.ini";
if (File.Exists(path))
{
StreamReader sr = new StreamReader(File.OpenRead(path));
while ((data = sr.ReadLine()) != "")
{
//.....
}
}

============================================================

StreamWriter sw = new StreamWriter(File.OpenWrite(path));
sw.WriteLine("Something");
sw.Close();

沒有留言: