[C#] 纯文本查看 复制代码         public static string GetMD5WithFilePath(string filePath)
        {
            using (FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                byte[] hash_byte = md5.ComputeHash(file);
                string str = System.BitConverter.ToString(hash_byte);
                str = str.Replace("-", "");
                file.Close();
                file.Dispose();
                return str.ToLower();
            }
        } 
 
当在其他线程执行删除文件后,using那一行会报 
 System.Reflection.TargetInvocationException: 操作过程中出现异常,结果无效。  有关异常的详细信息,请查看 InnerException。 ---> System.IO.FileNotFoundException: 未能找到文件  错误?求解 
 |