FileStream f=new FileStream("c:\\file.xml",FileMode.Create);
StreamWriter sf=new StreamWriter(f);
sf.WriteLine(stroka);
sf.Close();
sf.Dispose();
f.Close();
f.Dispose();
FileStream f1=new FileStream("c:\\file.xml",FileMode.Open);
StreamReader sr=new StreamReader("c:\\file.xml");
xmlreader=new XmlTextReader(sr);
sr.Close();
sr.Dispose();
f1.Close();
f1.Dispose();
我收到此錯誤:文件的流正在被另一個進程使用
The process cannot access the file 'c:\file.xml' because it is being used by another process
我已經關閉了所有和配置所有。有什麼問題?
我有這個問題,請注意,您應該「關閉」流「之前」處置 – Mironline 2012-03-28 10:42:31
@Mironline。這是自動完成的。閱讀**我的答案全部**你可以看到什麼是Dispose在做[這裏](http://stackoverflow.com/a/911431/601179) – gdoron 2012-03-28 10:46:12