El objeto ISEFileCollection

El objeto ISEFileCollection es una colección de objetos ISEFile. Un ejemplo es la colección $psISE.CurrentPowerShellTab.Files.

Métodos

Add( [RutaCompleta] )

Se admite en Windows PowerShell ISE 2.0 y versiones posteriores.

Crea y devuelve un archivo sin título nuevo y lo agrega a la colección. La propiedad IsUntitled del archivo recién creado es $true.

[RutaCompleta]: cadena opcional. La ruta completamente especificada del archivo. Se genera una excepción si incluye el parámetro FullPath y una ruta de acceso relativa, o bien si utiliza un nombre de archivo en lugar de la ruta de acceso completa.

# 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( Archivo, [Force] )

Se admite en Windows PowerShell ISE 2.0 y versiones posteriores.

Quita un archivo especificado en la pestaña actual de PowerShell.

File: cadena. Archivo ISEFile que quiere quitar de la colección. Si el archivo no se ha guardado, este método inicia una excepción. Utilice el parámetro modificador Force parámetro para forzar la eliminación de un archivo no guardado.

[Force]: booleano opcional. Si se establece en $true, concede permiso para quitar el archivo incluso si no se ha guardado después del último uso. El valor predeterminado es $false.

# Removes the first opened file from the file collection associated with the current PowerShell tab.
# If the file has not 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 has not been saved.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.Remove($firstfile, $true)

SetSelectedFile( archivoSeleccionado )

Se admite en Windows PowerShell ISE 2.0 y versiones posteriores.

Selecciona el archivo que especifica el parámetro SelectedFile.

SelectedFile: Microsoft.PowerShell.Host.ISE.ISEFile. Archivo ISEFile que quiere seleccionar.

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

Consulte también