我如何在程序上在特定的子文件夹上打开Azure Storage Explorer?

问题描述 投票:0回答:1
我可以为用户提供一个很好的体验,可以使用以下代码打开Windows File Explorer。

var psi = new System.Diagnostics.ProcessStartInfo() { FileName = startPath, UseShellExecute = true }; System.Diagnostics.Process.Start(psi);

我想为存储资源管理器做类似的事情。 我尝试了以下
var arguments = $"--account-name mystorage --container images --path mysubfolder";

var userDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

// get the path to the Azure Storage Explorer executable
var workingDirectory = userDirectory+"\\Programs\\Microsoft Azure Storage Explorer";
var fullExeFileName = workingDirectory+"\\StorageExplorer.exe";

if (!Directory.Exists(workingDirectory)) 
{
    throw new DirectoryNotFoundException(workingDirectory); 
}

if (!File.Exists(fullExeFileName)) 
{
    throw new FileNotFoundException(fullExeFileName); 
}
       
var processStartInfo = new ProcessStartInfo
        {
            FileName = fullExeFileName,
            Arguments = arguements,
            UseShellExecute = true,
            WorkingDirectory = workingDirectory
        };

Process.Start(processStartInfo);

在相关子文件夹中打开storageExplorer,但不会打开storageExplorer。

我在浏览器中打开了一个直接链接,但这向用户提供了一个对话框,这不是我想要的。

我尝试了Visual Studio命令提示符,但无法使参数有效。
具有命令:

storageexplorer "--account-name mystorage"

生成以下日志文件:

[2025-01-26T22:15:40.815Z] (main:17928) <NONE> Log level: info [2025-01-26T22:15:40.815Z] (main:17928) <INFO> Startup app state: { lastWindowState: { rect: { x: 900, y: 652, width: 1760, height: 902 }, maximized: false } } [2025-01-26T22:15:40.907Z] (main:17928) <INFO> Calling handleQuitOrRelaunch from quit [2025-01-26T22:15:40.907Z] (main:17928) <INFO> Quitting, sessionEnded: false, force: true, quitOrRelaunch: quit [2025-01-26T22:15:40.907Z] (main:17928) <ERRO> Error occurred while trying to actually quit: {} [2025-01-26T22:15:40.908Z] (main:17928) <INFO> Calling quit, bye!

我如何在程序上在特定的子文件夹上打开Azure Storage Explorer?

I agree with stuartd's comment, Azure Storage Explorer does not support direct navigation to a specific container or subfolder via command-line arguments.
现在,您需要使用直接链接来访问特定子文件夹的Azure存储资源管理器。
c# azure-blob-storage
1个回答
0
投票

using System; using System.Diagnostics; class Program { static void Main() { string storageExplorerUri = "storageexplorer://?v=2&tenantId=(tenant-id)" + "&type=blobPath&path=<path name>%2F&container=(container name)" + "&serviceEndpoint=https%3A%2F%2F(account name).blob.core.windows.net%2F" + "&storageAccountId=%2Fsubscriptions%2Fxxxx%2FresourceGroups%2Fxxx%2Fproviders%2FMicrosoft.Storage%2FstorageAccounts%2Fxxx" + "&subscriptionId=xxxx"; Process.Start(new ProcessStartInfo { FileName = storageExplorerUri, UseShellExecute = true }); Console.WriteLine("Opening Storage Explorer..."); } }

上面的代码将打开Azure Storage Explorer,并导航到对话框,如下:

示例:

用户授权:

现在它将导航到Azure Storage Explorer中的特定目录。

enter image description here港:

enter image description here参考:

ZUREStorage Explorer Direct Link |微软学习

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.