判断一个文件是否可以使用

        有时候在获取共享目录下的文件是发现该文件不可用,出现这种情况可能是该文件正在上传,还没有完全上传结束。

      因此需要判断一下该文件是否可用

        public static bool IsFileCanUse(string filepath)
        {
            try
            {
                File.Move(filepath, filepath);
                return true;
            }
            catch
            {
                return false;
            }
        }

reread:
if(FileHelper.IsFileCanUse(filefullpath)==false)
{
goto reread;
}

原文地址:https://www.cnblogs.com/amylis_chen/p/2816262.html