Function Select-FileWindow
{
param(
[string]$Title = "Select CSV",
[string]$Directory = "C:",
[string]$Filter = "CSV Files (*.csv)|*.csv"
)
[System.Reflection.Assembly]:: LoadWithPartialName("System. Windows.Forms") | Out-Null
$objForm = New-Object System.Windows.Forms. OpenFileDialog
$objForm.InitialDirectory = $Directory
$objForm.Filter = $Filter
$objForm.Title = $Title
$objForm.ShowHelp = $true
$Show = $objForm.ShowDialog()
If ($Show -eq "OK")
{
Return $objForm.FileName
}
Else
{
Write-Error "Operation cancelled by user."
}
}
No comments:
Post a Comment