private List<string> readFileToList(string fileName)
{
FileStream fs = new FileStream(fileName
List<string> list = new List<string>();
StreamReader m_streamReader = new StreamReader(fs);//中文亂碼加上System
//使用StreamReader類來讀取文件
m_streamReader
// 從數據流中讀取每一行
string strLine = m_streamReader
while (strLine != null)
{
list
strLine = m_streamReader
}
//關閉此StreamReader對象
m_streamReader
return list;
}
private void writeListToFile(List<string> pList
{
//創建一個文件流
System
StreamWriter m_streamWriter = new StreamWriter(fs);
m_streamWriter
// 使用StreamWriter來往文件中寫入內容
m_streamWriter
// 把richTextBox
for (int i =
{
m_streamWriter
}
//關閉此文件
m_streamWriter
m_streamWriter
}
//測試 by gisoracle
private void button
{
List<string> slist = readFileToList(@
writeListToFile(slist
}
From:http://tw.wingwit.com/Article/program/net/201311/13050.html