Compartilhar via


O Objeto ISEFile

Um objeto ISEFile representa um arquivo no Ambiente Integrado de Scripting (ISE) do Windows PowerShell. É uma instância da classe Microsoft.PowerShell.Host.ISE.ISEFile . Este tópico lista seus métodos e propriedades membros. Os $psISE.CurrentFile arquivos e na coleção Arquivos em uma aba PowerShell são todos instâncias da classe Microsoft.PowerShell.Host.ISE.ISEFile .

Methods

Salve( [salvandoCodificando] )

Suportado no Windows PowerShell ISE 2.0 e versões posteriores.

Salva o arquivo no disco.

[saveEncoding] - opcional System.Text.Encoding Um parâmetro opcional de codificação de caracteres a ser usado para o arquivo salvo. O valor padrão é UTF8.

Exceptions

  • System.IO.IOException: O arquivo não pôde ser salvo.
# 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 do arquivo, [saveEncoding])

Suportado no Windows PowerShell ISE 2.0 e versões posteriores.

Salva o arquivo com o nome e a codificação especificados.

nome do arquivo - String O nome a ser usado para salvar o arquivo.

[saveEncoding] - opcional System.Text.Encoding Um parâmetro opcional de codificação de caracteres a ser usado para o arquivo salvo. O valor padrão é UTF8.

Exceptions

  • System.ArgumentNullException: O parâmetro do nome do arquivo é nulo.
  • System.ArgumentException: O parâmetro do nome do arquivo está vazio.
  • System.IO.IOException: O arquivo não pôde ser salvo.
# 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)

Propriedades

DisplayName

Suportado no Windows PowerShell ISE 2.0 e versões posteriores.

A propriedade somente leitura que recebe a string que contém o nome de exibição desse arquivo. O nome é mostrado na aba Arquivo no topo do editor. A presença de um asterisco (*) no final do nome indica que o arquivo tem alterações que não foram salvas.

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

Editor

Suportado no Windows PowerShell ISE 2.0 e versões posteriores.

A propriedade somente leitura que recebe o objeto editor usado para o arquivo especificado.

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

Codificação

Suportado no Windows PowerShell ISE 2.0 e versões posteriores.

A propriedade somente leitura que obtém a codificação original do arquivo. Este é um objeto System.Text.Encoding .

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

FullPath

Suportado no Windows PowerShell ISE 2.0 e versões posteriores.

A propriedade somente leitura que recebe a string que especifica o caminho completo do arquivo aberto.

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

IsSaved

Suportado no Windows PowerShell ISE 2.0 e versões posteriores.

A propriedade Booleana somente leitura que retorna $true se o arquivo foi salvo após sua última modificação.

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

IsUntitled

Suportado no Windows PowerShell ISE 2.0 e versões posteriores.

A propriedade somente leitura que retorna $true se o arquivo nunca recebeu um título.

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

Consulte Também