日期:2014-05-18 浏览次数:20787 次
private void button1_Click(object sender, EventArgs e) { FileStream vFileStream = new FileStream(@"c:\temp\temp.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); StreamReader vStreamReader = new StreamReader(vFileStream, Encoding.Default); Console.WriteLine(vStreamReader.ReadToEnd()); } private FileStream writeStream = new FileStream(@"c:\temp\temp.txt", FileMode.Append, FileAccess.Write, FileShare.ReadWrite); private StreamWriter streamWriter; private void button2_Click(object sender, EventArgs e) { if (streamWriter == null) streamWriter = new StreamWriter(writeStream, Encoding.Default); streamWriter.WriteLine("Zswang路过"); streamWriter.Flush(); }