Skip to content

Commit 38c1450

Browse files
Merge pull request #616 from tylerl0706/enumerate-to-get
change Enumerate* to Get*
2 parents dafbbc7 + 09cbdaa commit 38c1450

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/PowerShellEditorServices/Workspace/Workspace.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private IEnumerable<string> RecursivelyEnumerateFiles(string folderPath)
241241

242242
try
243243
{
244-
IEnumerable<string> subDirs = Directory.EnumerateDirectories(folderPath);
244+
IEnumerable<string> subDirs = Directory.GetDirectories(folderPath);
245245
foreach (string dir in subDirs)
246246
{
247247
foundFiles =
@@ -274,14 +274,26 @@ private IEnumerable<string> RecursivelyEnumerateFiles(string folderPath)
274274
{
275275
foundFiles =
276276
foundFiles.Concat(
277-
Directory.EnumerateFiles(
277+
Directory.GetFiles(
278278
folderPath,
279279
pattern));
280280
}
281-
catch (UnauthorizedAccessException e)
281+
catch (DirectoryNotFoundException e)
282282
{
283283
this.logger.WriteException(
284-
$"Could not enumerate files in the path '{folderPath}' due to a file not being accessible",
284+
$"Could not enumerate files in the path '{folderPath}' due to a path being an invalid path",
285+
e);
286+
}
287+
catch (PathTooLongException e)
288+
{
289+
this.logger.WriteException(
290+
$"Could not enumerate files in the path '{folderPath}' due to a path being too long",
291+
e);
292+
}
293+
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
294+
{
295+
this.logger.WriteException(
296+
$"Could not enumerate files in the path '{folderPath}' due to a path not being accessible",
285297
e);
286298
}
287299
}

0 commit comments

Comments
 (0)