Skip to content

Commit 30e13e7

Browse files
authored
Fix: Fixed an issue with opening shell locations on startup (#17885)
1 parent 5cfa84f commit 30e13e7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Files.App/Helpers/Win32/Win32Helper.Shell.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ namespace Files.App.Helpers
1313
/// </summary>
1414
public static partial class Win32Helper
1515
{
16-
private readonly static ShellFolder _controlPanel = new(Shell32.KNOWNFOLDERID.FOLDERID_ControlPanelFolder);
17-
18-
private readonly static ShellFolder _controlPanelCategoryView = new("::{26EE0668-A00A-44D7-9371-BEB064C98683}");
19-
2016
public static async Task<(ShellFileItem Folder, List<ShellFileItem> Enumerate)> GetShellFolderAsync(string path, bool getFolder, bool getEnumerate, int from, int count, params string[] properties)
2117
{
2218
if (path.StartsWith("::{", StringComparison.Ordinal))
@@ -32,6 +28,8 @@ public static partial class Win32Helper
3228
try
3329
{
3430
using var shellFolder = ShellFolderExtensions.GetShellItemFromPathOrPIDL(path) as ShellFolder;
31+
using ShellFolder _controlPanel = new(Shell32.KNOWNFOLDERID.FOLDERID_ControlPanelFolder);
32+
using ShellFolder _controlPanelCategoryView = new("::{26EE0668-A00A-44D7-9371-BEB064C98683}");
3533

3634
if (shellFolder is null ||
3735
(_controlPanel.PIDL.IsParentOf(shellFolder.PIDL, false) ||

src/Files.App/MainWindow.xaml.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,14 @@ private async Task InitializeFromCmdLineArgsAsync(Frame rootFrame, ParsedCommand
253253
{
254254
async Task PerformNavigationAsync(string payload, string selectItem = null)
255255
{
256+
if (!string.IsNullOrEmpty(payload))
257+
{
258+
payload = Constants.UserEnvironmentPaths.ShellPlaces.Get(payload.ToUpperInvariant(), payload);
259+
var folder = (StorageFolder)await FilesystemTasks.Wrap(() => StorageFolder.GetFolderFromPathAsync(payload).AsTask());
260+
if (folder is not null && !string.IsNullOrEmpty(folder.Path))
261+
payload = folder.Path; // Convert short name to long name (#6190)
262+
}
263+
256264
var generalSettingsService = Ioc.Default.GetService<IGeneralSettingsService>();
257265

258266
double boundsWidth = 0;

0 commit comments

Comments
 (0)