tankcr

input gui

Jul 18th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function Select-FolderDialog
  2. {
  3.     param([string]$Description="Select Folder to place results in",[string]$RootFolder="Desktop")
  4.  
  5.  [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") |
  6.      Out-Null    
  7.  
  8.    $objForm = New-Object System.Windows.Forms.FolderBrowserDialog
  9.         $objForm.Rootfolder = $RootFolder
  10.         $objForm.Description = $Description
  11.         $Show = $objForm.ShowDialog()
  12.         If ($Show -eq "OK")
  13.         {
  14.             Return $objForm.SelectedPath
  15.         }
  16.         Else
  17.         {
  18.             Write-Error "Operation cancelled by user."
  19.         }
  20.     }
  21.  
  22. Function Get-FileName($initialDirectory)
  23. {
  24.     [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
  25.    
  26.     $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
  27.     $OpenFileDialog.initialDirectory = $initialDirectory
  28.     $OpenFileDialog.FileName = "Select Input File"
  29.     $OpenFileDialog.filter = "CSV (*.csv)| *.csv"
  30.     $OpenFileDialog.ShowDialog() | Out-Null
  31. }
  32.  
  33.    
  34.     $inputfile = Get-FileName "C:\temp"
  35.     $inputdata = get-content $inputfile
  36.     $folder = Select-FolderDialog
Advertisement
Add Comment
Please, Sign In to add comment