|
@@ -8,7 +8,9 @@ public static class FileListRetriever
|
|
public static IEnumerable<string> RetrieveFiles(FileInfo fileInfo)
|
|
public static IEnumerable<string> RetrieveFiles(FileInfo fileInfo)
|
|
{
|
|
{
|
|
if (fileInfo == null)
|
|
if (fileInfo == null)
|
|
|
|
+ {
|
|
return new List<string>();
|
|
return new List<string>();
|
|
|
|
+ }
|
|
|
|
|
|
// Check if the file is a directory or not
|
|
// Check if the file is a directory or not
|
|
var isDirectory = fileInfo.Attributes.HasFlag(FileAttributes.Directory);
|
|
var isDirectory = fileInfo.Attributes.HasFlag(FileAttributes.Directory);
|
|
@@ -16,7 +18,9 @@ public static class FileListRetriever
|
|
// Get the directory path based on whether the file is a directory or not
|
|
// Get the directory path based on whether the file is a directory or not
|
|
var directory = isDirectory ? fileInfo.FullName : fileInfo.DirectoryName;
|
|
var directory = isDirectory ? fileInfo.FullName : fileInfo.DirectoryName;
|
|
if (directory is null)
|
|
if (directory is null)
|
|
|
|
+ {
|
|
return new List<string>();
|
|
return new List<string>();
|
|
|
|
+ }
|
|
|
|
|
|
string[] enumerable;
|
|
string[] enumerable;
|
|
// Check if the subdirectories are to be included in the search
|
|
// Check if the subdirectories are to be included in the search
|
|
@@ -31,7 +35,7 @@ public static class FileListRetriever
|
|
files = Directory.EnumerateFiles(directory, "*.*", new EnumerationOptions
|
|
files = Directory.EnumerateFiles(directory, "*.*", new EnumerationOptions
|
|
{
|
|
{
|
|
AttributesToSkip = default, // Pick up hidden files
|
|
AttributesToSkip = default, // Pick up hidden files
|
|
- RecurseSubdirectories = true,
|
|
|
|
|
|
+ RecurseSubdirectories = true
|
|
}).AsParallel();
|
|
}).AsParallel();
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -47,7 +51,7 @@ public static class FileListRetriever
|
|
}
|
|
}
|
|
catch (Exception exception)
|
|
catch (Exception exception)
|
|
{
|
|
{
|
|
- DebugHelper.LogDebug(nameof(FileSortHelper), nameof(RetrieveFiles), exception);
|
|
|
|
|
|
+ DebugHelper.LogDebug(nameof(FileListRetriever), nameof(RetrieveFiles), exception);
|
|
return new List<string>();
|
|
return new List<string>();
|
|
}
|
|
}
|
|
|
|
|