Partilhar via


O Objeto ISEFileCollection

O objeto ISEFileCollection é uma coleção de objetos ISEFile . Um exemplo é a $psISE.CurrentPowerShellTab.Files coleção.

Methods

Add( [FullPath] )

Suportado no Windows PowerShell ISE 2.0 e posteriores.

Cria e devolve um novo ficheiro sem título e adiciona-o à coleção. A propriedade IsUntitled do ficheiro recém-criado é $true.

  • [FullPath] - String opcional - O caminho totalmente especificado do ficheiro. Uma exceção é gerada se incluir o parâmetro FullPath e um caminho relativo, ou se usar um nome de ficheiro em vez do caminho completo.
# 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] )

Suportado no Windows PowerShell ISE 2.0 e posteriores.

Remove um ficheiro especificado do separador atual do PowerShell.

Ficheiro - String O ficheiro ISEFile que pretende remover da coleção. Se o ficheiro não tiver sido guardado, este método lança uma exceção. Usa o parâmetro Force switch para forçar a remoção de um ficheiro não guardado.

[Forçar] - Booleano opcional Se definido para $true, concede permissão para remover o ficheiro mesmo que não tenha sido guardado após a última utilização. A predefinição é $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 )

Suportado no Windows PowerShell ISE 2.0 e posteriores.

Seleciona o ficheiro especificado pelo parâmetro SelectedFile .

Ficheiro Selecionado - Microsoft.PowerShell.Host.ISE.ISEFile O ficheiro ISEFile que pretende selecionar.

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

Ver também