您现在的位置是:网站首页> 编程资料编程资料
Powershell使用OpenFileDialog打开文件示例_PowerShell_
2023-05-26
433人已围观
简介 Powershell使用OpenFileDialog打开文件示例_PowerShell_
支持所有版本。
要添加某些文件到你的脚本中,下面一个例子使用一个文件对话框来获得一个文件:
复制代码 代码如下:
function Show-OpenFileDialog
{
param
($Title = 'Pick a File', $Filter = 'All|*.*|PowerShell|*.ps1')
$type = 'Microsoft.Win32.OpenFileDialog'
$dialog = New-Object -TypeName $type
$dialog.Title = $Title
$dialog.Filter = $Filter
if ($dialog.ShowDialog() -eq $true)
{
$dialog.FileName
}
else
{
Write-Warning 'Cancelled'
}
}
现在你还可以控制这个窗体抬头和文件类型。
您可能感兴趣的文章:
相关内容
- PowerShell中调用WPF生成炫酷窗口实例_PowerShell_
- Powershell中可以使用的.Net实用静态方法_PowerShell_
- Powershell获取系统中所有可停止的服务_PowerShell_
- 用PowerShell代替批处理吧!_PowerShell_
- Powershell中请求WebServices并以JSON格式输出结果_PowerShell_
- Powershell中阻止”确认提示”的方法_PowerShell_
- PowerShell中实现混淆密码示例_PowerShell_
- Powershell展开对象数据结构并以JSON格式输出_PowerShell_
- PowerShell检查网卡状态和对应的电源设置_PowerShell_
- PowerShell添加本地账户脚本分享_PowerShell_
