Ejemplo n.º 1
0
 private static void RunAction(object action)
 {
     try
     {
         ((Action)action)();
     }
     catch (Exception e)
     {
         DebugUtils.LogError(DebugUtils.Type.Important, "RunAction error: " + e.ToString());
     }
     finally
     {
         Interlocked.Decrement(ref numThreads);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Get the file MD5 information for comparison updates
 /// </summary>
 /// <param name="filePath"></param>
 /// <returns></returns>
 public static string GetFileMd5(string filePath)
 {
     try
     {
         FileStream fs   = new FileStream(filePath, FileMode.Open);
         int        len  = ( int )fs.Length;
         byte[]     data = new byte[len];
         fs.Read(data, 0, len);
         fs.Close();
         MD5           md5     = new MD5CryptoServiceProvider();
         byte[]        result  = md5.ComputeHash(data);
         StringBuilder fileMD5 = new StringBuilder();
         for (var i = 0; i < result.Length; i++)
         {
             fileMD5.Append(Convert.ToString(result[i], 16));
         }
         return(fileMD5.ToString());
     }
     catch (FileNotFoundException e)
     {
         DebugUtils.LogError(DebugUtils.Type.Special, "Get the file MD5 err, msg:" + e.Message);
         return("");
     }
 }