0

false无论file是已经打开还是关闭,这总是返回。

直到昨天它都运行良好;今天它没有按预期工作。

public bool isOpen(FileInfo file)
{
    FileStream stream = null;

    try
    {
        stream = file.Open(FileMode.Open);
    }
    catch (Exception ex)
    {
        Logger.Error(ex.Message);
        return true;
    }
    finally
    {
        if (stream != null)
            stream.Close();
    }
    return false;
}
4

0 回答 0