Exemple #1
0
 private void Calc()
 {
     try
     {
         while (_fileinfo.Status != StatusWork.Complite)
         {
             while (_fileinfo.TryDequeue(out var resultFile))
             {
                 using (var md5Hash = MD5.Create())
                 {
                     using (var stream = File.OpenRead(resultFile))
                     {
                         var hash = new CustomStorage(resultFile, BitConverter.ToInt32(md5Hash.ComputeHash(stream), 0));
                         _hashQueue.Enqueue(hash);
                     }
                 }
             }
             _fileinfo.AutoResetEvent.WaitOne();
         }
         while (_fileinfo.TryDequeue(out var resultFile))
         {
             using (var md5Hash = MD5.Create())
             {
                 using (var stream = File.OpenRead(resultFile))
                 {
                     var hash = new CustomStorage(resultFile, BitConverter.ToInt32(md5Hash.ComputeHash(stream), 0));
                     _hashQueue.Enqueue(hash);
                 }
             }
         }
     }
     catch (Exception e)
     {
         var log = new CustomStorage("", e.Message, e.StackTrace);
         Log.BuildLogMessage(log);
     }
 }
Exemple #2
0
 private void Scan(string dirPath)
 {
     try
     {
         foreach (var dir in Directory.EnumerateDirectories(dirPath))
         {
             Scan(dir);
         }
         foreach (var item in Directory.GetFiles(dirPath))
         {
             ListFileName.Add(item);
             FileQueue.Enqueue(item);
         }
     }
     catch (Exception e)
     {
         var log = new CustomStorage(dirPath, e.Message, e.StackTrace);
         Log.BuildLogMessage(log);
     }
 }