【发布时间】:2012-03-30 20:06:43
【问题描述】:
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”,因为它正在 被另一个进程使用。
为什么?如何关闭文件?
【问题讨论】: