ISEFile 对象The ISEFile Object

Save( [saveEncoding] )Save( [saveEncoding] )

在 Windows PowerShell ISE 2.0 和更高版本中受支持。

将该文件保存到磁盘。

[saveEncoding] - 可选 ,用于已保存文件的可选字符编码参数。默认值是 UTF8

例外Exceptions

  • System.IO.IOException:无法保存文件。

在 Windows PowerShell ISE 2.0 和更高版本中受支持。

使用指定的文件名和编码保存文件。

[saveEncoding] - 可选 ,用于已保存文件的可选字符编码参数。默认值是 UTF8

例外Exceptions

  • System.ArgumentNullException:文件名参数为 null。
  • System.ArgumentException:文件名参数为空。
  • System.IO.IOException:无法保存文件。
  1. $fullpath = "c:\temp\newname.txt"
  2. $psISE.CurrentFile.SaveAs($fullPath)

DisplayNameDisplayName

在 Windows PowerShell ISE 2.0 和更高版本中受支持。

只读属性,可获取包含此文件显示名称的字符串。名称显示在编辑器顶部的“文件”选项卡上。名称结尾处存在星号 (*),表示文件具有未保存的更改。

在 Windows PowerShell ISE 2.0 和更高版本中受支持。

只读属性,可获取用于指定文件的编辑器对象

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

编码Encoding

只读属性,可获取原始文件编码。这是一个 System.Text.Encoding 对象。

FullPathFullPath

在 Windows PowerShell ISE 2.0 和更高版本中受支持。

只读属性,可获取指定已打开文件的完整路径的字符串。

  1. # Shows the full path for the file.

在 Windows PowerShell ISE 2.0 和更高版本中受支持。

只读布尔属性,如果在最后一次修改文件后保存了文件,则返回 $true

IsUntitledIsUntitled

只读属性,如果从未指定文件标题,则返回 $true

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