虚位以待(AD)
虚位以待(AD)
首页 > 脚本专栏 > Powershell > Powershell使用OpenFileDialog打开文件示例

Powershell使用OpenFileDialog打开文件示例
类别:Powershell   作者:码皇   来源:互联网   点击:

这篇文章主要介绍了Powershell使用OpenFileDialog打开文件示例,本文直接给出示例代码,需要的朋友可以参考下

支持所有版本。

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

复制代码 代码如下:

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 打开文件