我的C#app正在锁定一个文件,我怎么能找到它的位置呢?

Dat*_*ase 4 c# file-io locking file

我正在编写检查文件路径计算哈希值(SHA1)并复制它们的代码.我确保我不会像使用它那样锁定它们

public static string SHA1(string filePath)
    {
        var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
        var formatted = string.Empty;
        using (var sha1 = new SHA1Managed())
        {
            byte[] hash = sha1.ComputeHash(fs);
            foreach (byte b in hash)
            {
                formatted += b.ToString("X2");
            }
        }
        return formatted;
    }
Run Code Online (Sandbox Code Playgroud)

那么我在Visual Studio中如何找到它锁定文件的位置呢?

Siv*_*pal 15

你能保持上面的语法并尝试一下吗?

using(var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
//Your code goes here.
} 
Run Code Online (Sandbox Code Playgroud)