【发布时间】:2025-12-09 16:25:01
【问题描述】:
我一直在尝试解决这个问题,但没有运气,我想弹出一个文件打开对话框,我已经能够使用我在网上找到的一个功能来完成,然后使用该文件在我的脚本中的位置更靠后,但我无法弄清楚。
这里是函数
Function Get-FileName()
{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") |
Out-Null
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.initialDirectory = "C:\Users\$($env:username)\Documents\"
$OpenFileDialog.filter = "CSV's (*.csv)| *.csv"
$OpenFileDialog.ShowDialog() | Out-Null
$OpenFileDialog.filename
}
我是 powershell 新手,所以我不确定函数是如何工作的。
【问题讨论】:
标签: file powershell fileopendialog