mirror of
https://github.com/microsoft/PowerToys
synced 2025-09-05 00:45:12 +00:00
After #39955, the "exe" items from the shell commands only ever have the "Run{as admin, as other user}" commands. This adds the rest of the "file" commands - copy path, open in explorer, etc. This shuffles around some commands into the toolkit and common commands project to make this easier. <img width="814" height="505" alt="image" src="https://github.com/user-attachments/assets/36ae2c75-d4d6-4762-98ec-796986f39c20" />
40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// 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.Diagnostics;
|
|
|
|
namespace Microsoft.CommandPalette.Extensions.Toolkit;
|
|
|
|
public partial class ShowFileInFolderCommand : InvokableCommand
|
|
{
|
|
private readonly string _path;
|
|
private static readonly IconInfo Ico = new("\uE838");
|
|
|
|
public CommandResult Result { get; set; } = CommandResult.Dismiss();
|
|
|
|
public ShowFileInFolderCommand(string path)
|
|
{
|
|
_path = path;
|
|
Name = Properties.Resources.ShowFileInFolderCommand_ShowInFolder;
|
|
Icon = Ico;
|
|
}
|
|
|
|
public override CommandResult Invoke()
|
|
{
|
|
if (Path.Exists(_path))
|
|
{
|
|
try
|
|
{
|
|
var argument = "/select, \"" + _path + "\"";
|
|
Process.Start("explorer.exe", argument);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
|
|
return Result;
|
|
}
|
|
}
|