public DirectoryScanner(string path, TreeView tree, string filePath, StatusUpdater updater, TextBox erroLogTextBox)
 {
     Path = path;
     _xmlEntryService = new XmlEntryService(filePath, erroLogTextBox);
     _treeEntryService = new TreeEntryService(tree, erroLogTextBox);
     _statusUpdater = updater;
 }
示例#2
0
        private void StartClick(object sender, EventArgs e)
        {
            if (_directorySelected && _fileSelected)
            {
                StopThread();
                var selectedPath = FolderBrowser.SelectedPath;

                try
                {
                    int countOfEntries = 0;
                    EventWaitHandle eventWaitHandle = new AutoResetEvent(false);
                    var helperThread = new Thread( () => Helpers.SetMaximumForProgressBar(selectedPath, ref countOfEntries, eventWaitHandle));
                    helperThread.Start();
                    eventWaitHandle.WaitOne();

                    progressBar.Maximum = countOfEntries;
                    progressBar.Value = 0;
                    var statusUpdater = new StatusUpdater(EnabledButtons){Label = CurrentFileNameLabel, ProgressBar = progressBar};
                    _scanner = new DirectoryScanner(selectedPath, treeView, saveFileDialog.FileName, statusUpdater, ErrorLogTextBox);

                    EnabledButtons(false);
                    _thread = new Thread(() => _scanner.Scan());
                    _thread.Start();
                }
                catch (ArgumentException)
                {
                    Helpers.WriteToLog(Resources.MainForm_DirectoryDoes_not_exsist, selectedPath);
                }
                catch (UnauthorizedAccessException)
                {
                    Helpers.WriteToLog(Resources.Access_denided_For, saveFileDialog.FileName);
                }
                catch (ThreadAbortException)
                { }
                catch (Exception ex)
                {
                    Helpers.WriteToLog(Resources.Error_message, ex.Message);
                }
            }
            else
            {
                MessageBox.Show(Resources.MainForm_StartClick_Please__select_file_and_folder, Resources.MainForm_Error,
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }