gpt4 book ai didi

c# - 我怎么知道文件已经打开或正在使用?

转载 作者:行者123 更新时间:2023-11-30 18:39:44 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Is there a way to check if a file is in use?
Check if a file is open

我怎么知道文件已经打开或正在使用。

public bool FileIsLocked(string strFullFileName)
{
bool blnReturn = false;
System.IO.FileStream fs;
try
{
fs = System.IO.File.Open(strFullFileName, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None);
fs.Close();
}
catch (System.IO.IOException ex)
{
blnReturn = true;
}
return blnReturn;
}

我发现上面的代码不能正常工作

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com