mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 11:17:53 +01:00
catch security exception and access denied exception while trying to read a file (#7140)
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox.Infrastructure.FileSystemHelper
|
||||
@@ -19,9 +21,9 @@ namespace Wox.Infrastructure.FileSystemHelper
|
||||
{
|
||||
return File.ReadAllLines(path);
|
||||
}
|
||||
catch (IOException ex)
|
||||
catch (System.Exception ex) when (ex is SecurityException || ex is UnauthorizedAccessException || ex is IOException)
|
||||
{
|
||||
Log.Info($"File {path} is being accessed by another process| {ex.Message}", GetType());
|
||||
Log.Info($"Unable to read File: {path}| {ex.Message}", GetType());
|
||||
|
||||
return new string[] { string.Empty };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user