Condividi tramite


L'Oggetto ISEFile

Un oggetto ISEFile rappresenta un file nell'Ambiente di Scripting Integrato (ISE) di Windows PowerShell. È un'istanza della classe Microsoft.PowerShell.Host.ISE.ISEFile . Questo argomento elenca i suoi metodi membri e le proprietà degli elementi. I $psISE.CurrentFile file e nella collezione File in una scheda PowerShell sono tutte istanze della classe Microsoft.PowerShell.Host.ISE.ISEFile .

Methods

Salva( [salvaCodifica] )

Supportato in Windows PowerShell ISE 2.0 e versioni successive.

Salva il file su disco.

[saveEncoding] - System.Text.Encoding opzionale Un parametro opzionale di codifica dei caratteri da utilizzare per il file salvato. Il valore predefinito è UTF8.

Exceptions

  • System.IO.IOException: Il file non è stato salvato.
# Save the file using the default encoding (UTF8)
$psISE.CurrentFile.Save()

# Save the file as ASCII.
$psISE.CurrentFile.Save([System.Text.Encoding]::ASCII)

# Gets the current encoding.
$myfile = $psISE.CurrentFile
$myfile.Encoding

SaveAs(nome file, [saveEncoding])

Supportato in Windows PowerShell ISE 2.0 e versioni successive.

Salva il file con il nome e la codifica specificati.

nome file - Stringa Il nome da usare per salvare il file.

[saveEncoding] - System.Text.Encoding opzionale Un parametro opzionale di codifica dei caratteri da utilizzare per il file salvato. Il valore predefinito è UTF8.

Exceptions

  • System.ArgumentNullException: Il parametro del nome file è nullo.
  • System.ArgumentException: Il parametro del nome file è vuoto.
  • System.IO.IOException: Il file non è stato salvato.
# Save the file with a full path and name.
$fullpath = "C:\temp\newname.txt"
$psISE.CurrentFile.SaveAs($fullPath)
# Save the file with a full path and name and explicitly as UTF8.
$psISE.CurrentFile.SaveAs($fullPath, [System.Text.Encoding]::UTF8)

Proprietà

Nome visualizzato

Supportato in Windows PowerShell ISE 2.0 e versioni successive.

La proprietà di sola lettura che ottiene la stringa che contiene il nome visualizzato di questo file. Il nome è mostrato nella scheda File in alto nell'editor. La presenza di un asterisco (*) alla fine del nome indica che il file presenta modifiche che non sono state salvate.

# Shows the display name of the file.
$psISE.CurrentFile.DisplayName

Redattore

Supportato in Windows PowerShell ISE 2.0 e versioni successive.

La proprietà di sola lettura che ottiene l'oggetto editor usato per il file specificato.

# Gets the editor and the text.
$psISE.CurrentFile.Editor.Text

Encoding

Supportato in Windows PowerShell ISE 2.0 e versioni successive.

La proprietà di sola lettura che ottiene la codifica originale del file. Questo è un oggetto System.Text.Encoding .

# Shows the encoding for the file.
$psISE.CurrentFile.Encoding

FullPath

Supportato in Windows PowerShell ISE 2.0 e versioni successive.

La proprietà di sola lettura che ottiene la stringa che specifica il percorso completo del file aperto.

# Shows the full path for the file.
$psISE.CurrentFile.FullPath

IsSaved

Supportato in Windows PowerShell ISE 2.0 e versioni successive.

La proprietà booleana di sola lettura che restituisce $true se il file è stato salvato dopo l'ultima modifica.

# Determines whether the file has been saved since it was last modified.
$myfile = $psISE.CurrentFile
$myfile.IsSaved

IsUntitled

Supportato in Windows PowerShell ISE 2.0 e versioni successive.

La proprietà di sola lettura che si restituisce $true se il file non ha mai ricevuto un titolo.

# Determines whether the file has never been given a title.
$psISE.CurrentFile.IsUntitled
$psISE.CurrentFile.SaveAs("temp.txt")
$psISE.CurrentFile.IsUntitled

Vedere anche