|
|
@ -65,17 +65,8 @@ namespace fileFinder |
|
|
|
private async Task<TreeNode> buildResultTree(TaskController controller, IProgress<ProgressReportModel> report) |
|
|
|
{ |
|
|
|
TreeNode itemsNode = new TreeNode(); |
|
|
|
List<String> foundFiles = new List<String>(); |
|
|
|
ProgressReportModel _report = new ProgressReportModel(); |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
foundFiles = Directory.GetFiles(curDirTextBox.Text, queryTextBox.Text, SearchOption.AllDirectories).ToList<String>(); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
MessageBox.Show(ex.Message, "Поиск не удался!"); |
|
|
|
} |
|
|
|
List<String> foundFiles = getFileList(curDirTextBox.Text, queryTextBox.Text); |
|
|
|
|
|
|
|
int counter = 0; |
|
|
|
foreach (String item in foundFiles) |
|
|
@ -83,9 +74,9 @@ namespace fileFinder |
|
|
|
while (controller.isPaused) |
|
|
|
{ |
|
|
|
Thread.Sleep(100); |
|
|
|
if (!mainController.isFormUpdatedAfterPause) |
|
|
|
if (!controller.isFormUpdatedAfterPause) |
|
|
|
{ |
|
|
|
mainController.isFormUpdatedAfterPause = true; |
|
|
|
controller.isFormUpdatedAfterPause = true; |
|
|
|
_report.progress = counter; |
|
|
|
_report.currentFileUrl = item; |
|
|
|
_report.currentTreeNode = (TreeNode) itemsNode.Clone(); |
|
|
@ -108,6 +99,20 @@ namespace fileFinder |
|
|
|
return itemsNode; |
|
|
|
} |
|
|
|
|
|
|
|
private List<string> getFileList (string directory, string nameQuery) |
|
|
|
{ |
|
|
|
List<String> fileList = new List<String>(); |
|
|
|
try |
|
|
|
{ |
|
|
|
fileList = Directory.GetFiles(directory, nameQuery, SearchOption.AllDirectories).ToList(); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
MessageBox.Show(ex.Message, "Не удалось получить доступ к файлу/папке"); |
|
|
|
} |
|
|
|
return fileList; |
|
|
|
} |
|
|
|
|
|
|
|
private string[] getFileContents (string fileUrl) |
|
|
|
{ |
|
|
|
try |
|
|
|