从 powershell 调用 FolderBrowserDialog [英] call FolderBrowserDialog from powershell

查看:55
本文介绍了从 powershell 调用 FolderBrowserDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类似于这个问题,运行以下代码后,浏览器对话框确实出现正确的按钮,但缺少通常显示可用文件夹的选择区域:

Similar to this question, after running the following code the browser dialog does appear with all the correct buttons, but the selection area that usally displays available folders is missing:

[void] [Reflection.Assembly]::LoadWithPartialName( 'System.Windows.Forms' )
$d = New-Object Windows.Forms.FolderBrowserDialog
$d.ShowDialog( )

推荐答案

我不久前遇到了这个问题,并在 MSDN 论坛上找到了以下 COM 解决方法:

I encountered this problem a while back and found the following COM workaround on the MSDN forums:

$app = new-object -com Shell.Application
$folder = $app.BrowseForFolder(0, "Select Folder", 0, "C:\")
if ($folder.Self.Path -ne "") {write-host "You selected " $folder.Self.Path}

http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.dotnet.framework.windowsforms.control&tid=3607557a-43b3-40bf-8276-be00526e0520&p=1

这篇关于从 powershell 调用 FolderBrowserDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆