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