Obiekt ISEFileCollection

Obiekt ISEFileCollection jest kolekcją obiektów ISEFile. Przykładem jest $psISE.CurrentPowerShellTab.Files kolekcja.

Metody

Add( [FullPath] )

Obsługiwane w programie Windows PowerShell ISE 2.0 lub nowszym.

Tworzy i zwraca nowy plik bez tytułu i dodaje go do kolekcji. Właściwość IsUntitled nowo utworzonego pliku to $true.

[FullPath] - Opcjonalny ciąg W pełni określona ścieżka pliku. Wyjątek jest generowany, jeśli dołączysz parametr FullPath i ścieżkę względną lub jeśli używasz nazwy pliku zamiast pełnej ścieżki.

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

Obsługiwane w programie Windows PowerShell ISE 2.0 lub nowszym.

Usuwa określony plik z bieżącej karty programu PowerShell.

Plik — ciąg plik ISEFile, który chcesz usunąć z kolekcji. Jeśli plik nie został zapisany, ta metoda zgłasza wyjątek. Użyj parametru Force switch, aby wymusić usunięcie niezapisanego pliku.

[Force] — opcjonalny wartość logiczna Jeśli ustawiono wartość $true, przyznaje uprawnienie do usuwania pliku, nawet jeśli nie został on zapisany po ostatnim użyciu. Wartość domyślna to $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( selectedFile )

Obsługiwane w programie Windows PowerShell ISE 2.0 lub nowszym.

Wybiera plik określony przez parametr SelectedFile .

SelectedFile — Microsoft.PowerShell.Host.ISE.ISEFile plik ISEFile, który chcesz wybrać.

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

Zobacz też