Skip to content

Instantly share code, notes, and snippets.

@FriedrichWeinmann
Created May 27, 2021 12:51
Show Gist options
  • Save FriedrichWeinmann/6e96d40c080d059ed570e4f660b725f9 to your computer and use it in GitHub Desktop.
Save FriedrichWeinmann/6e96d40c080d059ed570e4f660b725f9 to your computer and use it in GitHub Desktop.
function Show-SaveFileDialog {
[CmdletBinding()]
param (
[string]
$InitialDirectory = '.',
[string]
$Filter = '*.*',
$Filename
)
$saveFileDialog = [Windows.Forms.SaveFileDialog]::new()
$saveFileDialog.FileName = $Filename
$saveFileDialog.InitialDirectory = Resolve-Path -Path $InitialDirectory
$saveFileDialog.Title = "Save File to Disk"
$saveFileDialog.Filter = $Filter
$saveFileDialog.ShowHelp = $True
$result = $saveFileDialog.ShowDialog()
if ($result -eq "OK") {
$saveFileDialog.FileName
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment