Condividi tramite


L'oggetto ISEFileCollection

L'oggetto ISEFileCollection è una raccolta di oggetti ISEFile . Un esempio è la $psISE.CurrentPowerShellTab.Files collezione.

Methods

Add( [FullPath] )

Supportato in Windows PowerShell ISE 2.0 e versioni successive.

Crea e restituisce un nuovo file senza titolo e lo aggiunge alla collezione. La proprietà IsUntitled del file appena creato è $true.

  • [FullPath] - Stringa opzionale - Il percorso completamente specificato del file. Si genera un'eccezione se si include il parametro FullPath e un percorso relativo, oppure se si usa un nome file invece del percorso 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] )

Supportato in Windows PowerShell ISE 2.0 e versioni successive.

Rimuove un file specificato dalla scheda PowerShell corrente.

File - Stringa Il file ISEFile che vuoi rimuovere dalla collezione. Se il file non è stato salvato, questo metodo fa un'eccezione. Usa il parametro Force switch per forzare la rimozione di un file non salvato.

[Forza] - booleano opzionale Se impostato su $true, concede il permesso di rimuovere il file anche se non è stato salvato dopo l'ultimo utilizzo. Il valore predefinito è $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 )

Supportato in Windows PowerShell ISE 2.0 e versioni successive.

Seleziona il file specificato dal parametro SelectedFile .

SelectedFile - Microsoft.PowerShell.Host.ISE.ISEFile Il file ISEFile che vuoi selezionare.

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

Vedere anche