Skip to content

Commit 355bf0c

Browse files
authored
Code Quality: Fixed FileNotFoundException in WindowsIniService (#15802)
1 parent 78c85f0 commit 355bf0c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Files.App/Services/Windows/WindowsIniService.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) 2024 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4+
using System.IO;
5+
46
namespace Files.App.Services
57
{
68
/// <inheritdoc cref="IWindowsIniService"/>
@@ -9,19 +11,18 @@ public sealed class WindowsIniService : IWindowsIniService
911
/// <inheritdoc/>
1012
public List<IniSectionDataItem> GetData(string filePath)
1113
{
12-
var iniPath = SystemIO.Path.Combine(filePath);
13-
if (!SystemIO.File.Exists(iniPath))
14+
if (!File.Exists(filePath))
1415
return [];
1516

1617
var lines = Enumerable.Empty<string>().ToList();
1718

1819
try
1920
{
20-
lines = SystemIO.File.ReadLines(iniPath)
21+
lines = File.ReadLines(filePath)
2122
.Where(line => !line.StartsWith(';') && !string.IsNullOrEmpty(line))
2223
.ToList();
2324
}
24-
catch (UnauthorizedAccessException)
25+
catch (Exception ex) when (ex is UnauthorizedAccessException || ex is FileNotFoundException)
2526
{
2627
return [];
2728
}

0 commit comments

Comments
 (0)