mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 19:49:15 +08:00
Add exceptions for unauth and arg not found when searching
This commit is contained in:
parent
ddbf23df68
commit
f05767afe8
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -157,18 +157,32 @@ namespace Wox.Plugin.Folder
|
|||||||
incompleteName = incompleteName.Substring(1);
|
incompleteName = incompleteName.Substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// search folder and add results
|
try
|
||||||
var fileSystemInfos = directoryInfo.GetFileSystemInfos(incompleteName, searchOption);
|
|
||||||
|
|
||||||
foreach (var fileSystemInfo in fileSystemInfos)
|
|
||||||
{
|
{
|
||||||
if ((fileSystemInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue;
|
// search folder and add results
|
||||||
|
var fileSystemInfos = directoryInfo.GetFileSystemInfos(incompleteName, searchOption);
|
||||||
|
|
||||||
var result =
|
foreach (var fileSystemInfo in fileSystemInfos)
|
||||||
fileSystemInfo is DirectoryInfo
|
{
|
||||||
? CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, query.ActionKeyword)
|
if ((fileSystemInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue;
|
||||||
: CreateFileResult(fileSystemInfo.FullName);
|
|
||||||
results.Add(result);
|
var result =
|
||||||
|
fileSystemInfo is DirectoryInfo
|
||||||
|
? CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, query.ActionKeyword)
|
||||||
|
: CreateFileResult(fileSystemInfo.FullName);
|
||||||
|
results.Add(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
if (e is UnauthorizedAccessException || e is ArgumentException)
|
||||||
|
{
|
||||||
|
results.Add(new Result { Title = e.Message, Score = 501 });
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
Loading…
Reference in New Issue
Block a user