在下面的代碼後的文件我得到的錯誤「流是不可寫」:無法寫入讀取
class Class1
{
private static void Main()
{
FileStream fs = new FileStream("C:\\fFile.txt",
FileMode.OpenOrCreate,
FileAccess.ReadWrite,
FileShare.ReadWrite);
StreamReader r = new StreamReader(fs);
string t = r.ReadLine();
r.Close();
Console.WriteLine(t);
StreamWriter w = new StreamWriter(fs);
w.WriteLine("string");
w.Flush();
w.Close();
fs.Close();
}
}
出現的錯誤在該行StreamWriter w = new StreamWriter(fs);
這是爲什麼?