我有以下 PowerShell 函数,它可以很好地工作,但是窗口会在 PowerShell ISE 后台打开。
# Shows folder browser dialog box and sets to variable
function Get-FolderName() {
Add-Type -AssemblyName System.Windows.Forms
$FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog -Property @{
SelectedPath = 'C:\Temp\'
ShowNewFolderButton = $false
Description = "Select Staging Folder."
}
# If cancel is clicked the script will exit
if ($FolderBrowser.ShowDialog() -eq "Cancel") {break}
$FolderBrowser.SelectedPath
} #end function Get-FolderName
我看到OpenFileDialog
类有一个.TopMost
属性,但似乎无法转移到FolderBrowserDialog
类。
我是否遗漏了什么?
OpenFileDialog
,而不是FolderBrowserDialog。 - Theo