手机
当前位置:查字典教程网 >脚本专栏 >PowerShell >Powershell使用OpenFileDialog打开文件示例
Powershell使用OpenFileDialog打开文件示例
摘要:支持所有版本。要添加某些文件到你的脚本中,下面一个例子使用一个文件对话框来获得一个文件:复制代码代码如下:functionShow-Open...

支持所有版本。

要添加某些文件到你的脚本中,下面一个例子使用一个文件对话框来获得一个文件:

复制代码 代码如下:

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使用OpenFileDialog打开文件示例】相关文章:

PowerShell中使用GetType获取变量数据类型

PowerShell中实现播放WAV音频文件

PowerShell中使用正则表达式匹配字符串实例

Powershell实现按类型排序

Powershell获取图片名字、文件夹及拍摄时间的例子

PowerShell使用Remove-Item命令删除文件、注册表项介绍

PowerShell中正则表达式使用例子

Windows Powershell 执行外部命令

Powershell脚本中包含文件资源的例子

PowerShell小技巧之使用Verb打开程序

精品推荐
分类导航