【发布时间】:2019-11-22 10:11:59
【问题描述】:
请告诉我为什么在这段代码中 SaveFileDialog() 会提示两次输入文件名。
Function output-scrub{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$global:SaveFileDialogNB = New-Object System.Windows.Forms.SaveFileDialog
$global:SaveFileDialogNB.initialDirectory = "\\server\folder"
$global:SaveFileDialogNB.filter = "All files (*.*)| *.*"
$global:SaveFileDialogNB.SupportMultiDottedExtensions = $true
#$global:SaveFileDialogNB.ShowDialog() | Out-Null
#just to display the filename value
$global:SaveFileDialogNB.filename
#get just filename and the extension into a variable
#$F1Filename = Split-Path $global:OpenFileDialog.filename -Leaf ---commented out, only here if we only want to show filename extension alone.
$global:SaveFileDialogNB.ShowDialog() | Out-Null
if($SaveFileDialogNB.ShowDialog() -eq 'OK'){
convertToHashTWO
}
return
}
function outPutScrubbedBalances{
output-scrub
write-host "file has been saved"
return
}
这让我发疯了。
【问题讨论】:
-
你给
$SaveFileDialogNB.ShowDialog()打了两次电话。 -
我用
$global:SaveFileDialogNB.ShowDialog() | Out-Null调用它第二次调用它在哪里? -
我把它注释掉了,现在它只提示一次,我只想了解现在是哪一块产生了提示。
标签: .net winforms powershell savefiledialog