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

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

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

 

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

 

 

 

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

posted @ 2012-12-13 14:16  星火卓越  阅读(191)  评论(0编辑  收藏  举报