DirectoryInfo dir=new DirectoryInfo(path);
if (!dir.Exists)
{
Directory.CreateDirectory(path);
File.Create(path + "\\file.xml");
StreamWriter sw =new StreamWriter(path + "\\file.xml");
sw.Flush();
sw.Write("<?xml version='1.0' encoding='utf-8' ?><project></project>");
}
錯誤:該進程無法訪問文件 'C: file.xml',因爲它正被另一個進程使用
The process cannot access the file 'C:\file.xml' because it is being used by another process.
爲什麼呢?如何關閉文件?
錯誤:不能將類型'System.IO.FileStream'隱式轉換爲'System.IO.StreamWriter' – user1263390 2012-03-30 20:17:54