Answers for "check file lock c#"

C#
0

check file lock c#

public bool IsFileLocked(string filePath)
{
    try
    {
        using (File.Open(filePath, FileMode.Open)){}
    }
    catch (IOException e)
    {
        var errorCode = Marshal.GetHRForException(e) & ((1 << 16) - 1);
        return errorCode == 32 || errorCode == 33;
    }
    return false;
}
Posted by: Guest on August-16-2021

Code answers related to "check file lock c#"

C# Answers by Framework

Browse Popular Code Answers by Language