System.IO.IOException: Sharing violation on path
if (!System.IO.File.Exists(filePath))
{
//System.IO.File.Create(filePath);
System.IO.File.Create(filePath);
}
检测文件是否存在,如果不存在,创建文件,提示出现sharing violation on path 错误
将代码改成如下问题便被解决:
if (!System.IO.File.Exists(filePath))
{
//System.IO.File.Create(filePath);
System.IO.File.Create(filePath).Dispose();
}