Sdílet prostřednictvím


Objekt ISEFileCollection

Objekt ISEFileCollection je kolekce objektů ISEFile . Příkladem je sbírka $psISE.CurrentPowerShellTab.Files .

Methods

Add( [FullPath] )

Podporováno ve Windows PowerShell ISE 2.0 a novějších.

Vytvoří a vrátí nový soubor bez názvu a přidá ho do kolekce. Vlastnost IsUntitled nově vytvořeného souboru je .$true

  • [FullPath] - Optional string - Plně specifikovaná cesta souboru. Výjimka se vygeneruje, pokud zahrnete parametr FullPath a relativní cestu, nebo pokud použijete název souboru místo celé cesty.
# 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] )

Podporováno ve Windows PowerShell ISE 2.0 a novějších.

Odstraní specifikovaný soubor z aktuální karty PowerShell.

Soubor - Řetězec Soubor ISEFile, který chcete odstranit ze sbírky. Pokud soubor nebyl uložen, tato metoda vyhodí výjimku. Použijte parametr Force switch k vynucení odstranění neuloženého souboru.

[Force] - volitelná Boolean Pokud je nastaveno na $true, dává povolení soubor odstranit, i když nebyl uložen po posledním použití. Výchozí hodnota je $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 )

Podporováno ve Windows PowerShell ISE 2.0 a novějších.

Vybere soubor specifikovaný parametrem SelectedFile .

SelectedFile - Microsoft.PowerShell.Host.ISE.ISEFile Soubor ISEFile, který chcete vybrat.

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

Viz také