/// <summary>
        /// Поиск файлов в выбранной папке (рекурсивно) и заполнение списка файлов
        /// </summary>
        /// <param name="path"></param>
        public static void Search(FileQueue fileQueue, string path)
        {
            string[] files       = Directory.GetFiles(path);
            string[] directories = Directory.GetDirectories(path);

            foreach (var file in files)
            {
                fileQueue.Enqueue(new FileInfo(file));
            }

            foreach (var dir in directories)
            {
                Search(fileQueue, dir);
            }
        }
Exemple #2
0
        protected override void OnFileFound(object sender, FileFoundEventArgs args)
        {
            var file   = args.Item;
            var target = FileUtils.GetDestinationFile(Source, file, Destination);

            // Block so we don't queue too many files at once.
            while (FileQueue.Count > MaxThreads * 5 && !cancellation.IsCancellationRequested)
            {
                Thread.Sleep(500);
            }

            if (cancellation.IsCancellationRequested)
            {
                return;
            }

            FileQueue.Enqueue(new MultiThreadedFileOperationState(file, target));
        }
Exemple #3
0
 void Trace(string strLog)
 {
     if (strLog.Length == 0)
     {
         return;
     }
     lock (ObjLock) {
         try {
             if (GenerateLogName())
             {
                 UpdateFileQueue();
                 FileQueue.Enqueue(StrLogPath + "\\" + StrLogName);
             }
             StreamWriter streamWriter = File.AppendText(StrLogPath + "\\" + StrLogName);
             streamWriter.WriteLine(strLog);
             streamWriter.Flush();
             streamWriter.Close();
         } catch (Exception e) {
             Console.Error.WriteLine(e.Message);
         }
     }
 }