ISEFileCollection 对象是一组 ISEFile 对象。 比如收藏 $psISE.CurrentPowerShellTab.Files 。
Methods
Add( [FullPath] )
支持Windows PowerShell ISE 2.0及更高版本。
创建并返回一个新的无标题文件,并将其添加到集合中。 新创建文件的 IsUntitled 属性为 $true。
- [FullPath] - 可选字符串 - 文件的完整指定路径。 如果你包含 了 FullPath 参数和一个相对路径,或者你用文件名而不是完整路径,就会生成异常。
# Adds a new untitled file to the collection of files in the current PowerShell tab.
$newFile = $psISE.CurrentPowerShellTab.Files.Add()
# Adds a file specified by its full path to the collection of files in the current
# PowerShell tab.
$psISE.CurrentPowerShellTab.Files.Add("$PSHOME\Examples\profile.ps1")
Remove( File, [Force] )
支持Windows PowerShell ISE 2.0及更高版本。
从当前PowerShell标签页中移除指定文件。
文件 - 字符串 你想从集合中移除的ISEFile文件。 如果文件未被保存,该方法会抛出异常。 使用 强制 开关参数强制删除未保存的文件。
[强制] - 可选布尔值 如果设置为 $true,即使上次使用后文件未保存,也允许删除该文件。 默认值为 $false。
# Removes the first opened file from the file collection associated with the current
# PowerShell tab. If the file hasn't yet been saved, then an exception is generated.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.Remove($firstfile)
# Removes the first opened file from the file collection associated with the current
# PowerShell tab, even if it hasn't been saved.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.Remove($firstfile, $true)
SetSelectedFile( selectedFile )
支持Windows PowerShell ISE 2.0及更高版本。
选择由 SelectFile 参数指定的文件。
SelectedFile - Microsoft.PowerShell.Host.ISE.ISEFile 你想选择的 ISEFile 文件。
# Selects the specified file.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.SetSelectedFile($firstfile)