为排除word文档占用报错,记录下学习过程
//判断文件是否被占用
public static bool IsOccupied(string filePath)
{
FileStream stream = null;
try
{
stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.None);
return false;
}
catch
{
return true;
}
finally
{
if (stream != null)
{
stream.Close();
}
}
}
1万+

被折叠的 条评论
为什么被折叠?



