Answers for "browse for folder powershell"

0

browse for folder powershell

function BrowseForFolder($initialDirectory="")
{
    [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")|Out-Null
    $folderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog
    $folderBrowserDialog.Description = "Select a folder"
    $folderBrowserDialog.rootfolder = "MyComputer"
    $folderBrowserDialog.SelectedPath = $initialDirectory
    
   if ($folderBrowserDialog.ShowDialog() -eq "OK")
   {
      return $folderBrowserDialog.SelectedPath
   } else {
      return $initialDirectory
   }
}


$window.FindName("TargetDir").Text = $outDir

# Browse for target dir
$BrowseForTargetDirButton = $window.FindName("BrowseForTargetDir")
$BrowseForTargetDirButton.Add_Click({
   $currentDir = $window.FindName("TargetDir").Text
   $window.FindName("TargetDir").Text = BrowseForFolder($currentDir)
})
Posted by: Guest on October-06-2020

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language