call OpenFileDialog from powershell

前端 未结 3 735
情书的邮戳
情书的邮戳 2021-02-03 14:54

When I run the following, PowerShell hangs waiting for the dialog to close, even though the dialog is never displayed:

[void] [Reflection.Assembly]::LoadWithPart         


        
3条回答
  •  余生分开走
    2021-02-03 15:15

    I was able to duplicate your problem and found a workaround. I don't know why this happens, but it has happened to others.

    If you set the ShowHelp property to $true, you will get the dialog to come up properly.

    Example:

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

    Good Luck!

提交回复
热议问题