The ISEFileCollection object is a collection of ISEFile objects. The files collection associated with a PowerShellTab object is a member of this class. An example is the $psISE.CurrentPowerShellTab.Files collection.

Methods

Add()

Creates and returns a new untitled file and adds it to the collection. IsUntitled property of the newly created file is true.

# Adds a new file to the collection of files in the current PowerShell tab.
$newFile = $psISE.CurrentPowerShellTab.Files.Add() 
# Add the date as the first line of text in the new file.
$newFile.Editor.Text = "#" + (Get-Date) 

Add(string fullPath)

Adds a file specified by the fullPath parameter to the collection of files. IsUntitled property of the newly created file is false.

Note:

This method throws an exception if a relative path or a filename is used instead of the full path.

fullpath
The fully specified path of the file.

# Adds the file specified by its fullpath to the collection of files in the current PowerShell tab.
$psISE.CurrentPowerShellTab.Files.Add("$pshome\Examples\profile.ps1")

Remove(Microsoft.PowerShell.Host.ISE.ISEFile file)

Removes a specified file from the current PowerShell tab.

file
The ISEFile that you want to remove from the collection. If the file has not been saved, this method throws an exception. Use the following override to force the removal of an unsaved file.

# Removes the first opened file from the file collection associated with the current PowerShell tab.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.Remove($firstfile)

Remove(Microsoft.PowerShell.Host.ISE.ISEFile file, bool force)

Removes a specified file from the current PowerShell tab.

file
The ISEFile that you want to remove from the collection.

force
Boolean parameter that gives permission to remove the file even if it has not been saved since last use.

# Removes the first opened file from the file collection associated with the current PowerShell tab.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.Remove($firstfile, $true)

SetSelectedFile(Microsoft.PowerShell.Host.ISE.ISEFile selectedFile)

Selects the file specified by the selectedFile parameter.

selectedFile
The ISEFile that you would like to select.

# Selects the specified file.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.SetSelectedFile($firstfile)

See Also




Table Of Contents