ISEFileCollection-objektet

ISEFileCollection-objektet är en samling ISEFile-objekt. Ett exempel är samlingen $psISE.CurrentPowerShellTab.Files .

Metoder

Add( [FullPath] )

Stöds i Windows PowerShell ISE 2.0 och senare.

Skapar och returnerar en ny namnlös fil och lägger till den i samlingen. Egenskapen IsUntitled för den nyligen skapade filen är $true.

[FullPath] – Valfri sträng Den fullständigt angivna sökvägen till filen. Ett undantag genereras om du inkluderar parametern FullPath och en relativ sökväg, eller om du använder ett filnamn i stället för den fullständiga sökvägen.

# 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] )

Stöds i Windows PowerShell ISE 2.0 och senare.

Tar bort en angiven fil från den aktuella PowerShell-fliken.

Fil – Sträng DEN ISEFile-fil som du vill ta bort från samlingen. Om filen inte har sparats utlöser den här metoden ett undantag. Använd parametern Force switch för att framtvinga borttagning av en fil som inte har sparats.

[Framtvinga] – valfritt booleskt värde om det är inställt på $true, ger behörighet att ta bort filen även om den inte har sparats efter senaste användning. Standardvärdet är $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 )

Stöds i Windows PowerShell ISE 2.0 och senare.

Väljer den fil som anges av parametern SelectedFile .

SelectedFile – Microsoft.PowerShell.Host.ISE.ISEFile Den ISEFile-fil som du vill välja.

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

Se även