Freigeben über


Das ISEFileCollection-Objekt

Das ISEFileCollection--Objekt ist eine Auflistung von ISEFile--Objekten. Ein Beispiel ist die $psISE.CurrentPowerShellTab.Files-Auflistung.

Methodik

Add( [FullPath] )

Unterstützt in Windows PowerShell ISE 2.0 und höher.

Erstellt und gibt eine neue unbenannte Datei zurück und fügt sie der Auflistung hinzu. Die IsUntitled Eigenschaft der neu erstellten Datei ist $true.

[FullPath] – Optionale Zeichenfolge Der vollständig angegebene Pfad der Datei. Eine Ausnahme wird generiert, wenn Sie den FullPath Parameter und einen relativen Pfad einschließen oder einen Dateinamen anstelle des vollständigen Pfads verwenden.

# 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( Datei; [Force] )

Unterstützt in Windows PowerShell ISE 2.0 und höher.

Entfernt eine angegebene Datei aus der aktuellen PowerShell-Registerkarte.

Datei - Zeichenfolge Die ISEFile-Datei, die Sie aus der Auflistung entfernen möchten. Wenn die Datei nicht gespeichert wurde, löst diese Methode eine Ausnahme aus. Verwenden Sie die Force Switch-Parameter, um das Entfernen einer nicht gespeicherten Datei zu erzwingen.

[Force] - optional boolean If set to $true, grant permission to remove the file even if it has not been saved after last use. Der Standardwert ist $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 )

Unterstützt in Windows PowerShell ISE 2.0 und höher.

Wählt die Datei aus, die durch den parameter SelectedFile angegeben wird.

SelectedFile- - Microsoft.PowerShell.Host.ISE.ISEFile Die ISEFile-Datei, die Sie auswählen möchten.

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

Siehe auch