Created
December 20, 2021 06:19
-
-
Save lenicyl/90e2cfc0e3fa098a1ed50bf4297fbf9c to your computer and use it in GitHub Desktop.
[Powershell] Open File Dialog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# Source : | |
https://www.reddit.com/r/PowerShell/comments/m9iqz9/vs_code_open_file_dialog_not_taking_focus/ | |
Thanks kind redditor | |
#> | |
Function Get-FileName { | |
$null=[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | |
$OpenFileDialog = [System.Windows.Forms.OpenFileDialog]@{ | |
InitialDirectory = "$env:USERPROFILE\Desktop" | |
} | |
$null=$OpenFileDialog.ShowDialog() | |
$OpenFileDialog.FileName | |
} | |
$file = Get-FileName | |
Write-Host $file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment