看字面 不就是一个是写 一个是读吗?两个用在不同的地方 何来好坏之分
FileStream filest = new FileStream(@"c:\abc.txt", FileMode.Open, FileAccess.ReadWrite);
StreamReader sr = new StreamReader(filest);
string strLine = sr.ReadLine();
while(strLine!=null)
{
Console.WriteLine(strLine);
strLine = sr.ReadLine();
}
sr.Close();
filest.Close();
FileStream filewriter = new FileStream(@"C:\abc.txt", FileMode.Append, FileAccess.Write);
StreamWriter sw = new StreamWriter(filewriter);
for (char mychar = 'a'; mychar <= 'z'; mychar++)
{
sw.Write(mychar);
}
sw.Close();filewriter.Close();
FileStream filest = new FileStream(@"c:\abc.txt", FileMode.Open, FileAccess.ReadWrite);
StreamReader sr = new StreamReader(filest);
string strLine = sr.ReadLine();
while(strLine!=null)
{
Console.WriteLine(strLine);
strLine = sr.ReadLine();
}
sr.Close();
filest.Close();
http://www.bianceng.cn/Programming/csharp/200906/11379.htm |