ISEFile オブジェクトは、Windows PowerShell Integrated Scripting Environment (ISE) のファイルを表します。 これは、Microsoft.PowerShell.Host.ISE.ISEFile クラスのインスタンスです。 このトピックでは、そのメンバー メソッドとメンバー プロパティの一覧を示します。 PowerShell タブの $psISE.CurrentFile
と Files コレクション内のファイルは、すべての **Microsoft.PowerShell.Host.ISE.ISEFile クラスのインスタンスです。
メソッド
Save( [saveEncoding] )
Windows PowerShell ISE 2.0 以降でサポートされています。
ファイルをディスクに保存します。
[saveEncoding]
- 省略可能な System.Text.Encoding 保存されたファイルに使用する省略可能な文字エンコード パラメーターです。 既定値は UTF8 です。
例外
- System.IO.IOException: ファイルを保存できませんでした。
# 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(filename, [saveEncoding])
Windows PowerShell ISE 2.0 以降でサポートされています。
指定したファイル名とエンコードでファイルを保存します。
ファイル名の - 文字列 ファイルの保存に使用する名前。
[saveEncoding]
- 省略可能な System.Text.Encoding 保存されたファイルに使用する省略可能な文字エンコード パラメーターです。 既定値は UTF8 です。
例外
- System.ArgumentNullException: filename パラメーターが null です。
- System.ArgumentException: filename パラメーターが空です。
- System.IO.IOException: ファイルを保存できませんでした。
# 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)
プロパティ
DisplayName
Windows PowerShell ISE 2.0 以降でサポートされています。
このファイルの表示名を含む文字列を取得する読み取り専用プロパティ。 名前は、エディターの上部にある [ファイル] タブに表示されます。 名前の末尾にアスタリスク (*)
がある場合は、ファイルに保存されていない変更があることを示します。
# Shows the display name of the file.
$psISE.CurrentFile.DisplayName
編集者
Windows PowerShell ISE 2.0 以降でサポートされています。
指定したファイルに使用される エディター オブジェクト を取得する読み取り専用プロパティ。
# Gets the editor and the text.
$psISE.CurrentFile.Editor.Text
エンコーディング
Windows PowerShell ISE 2.0 以降でサポートされています。
元のファイル エンコードを取得する読み取り専用プロパティ。 これは、System.Text.Encoding オブジェクトです。
# Shows the encoding for the file.
$psISE.CurrentFile.Encoding
FullPath
Windows PowerShell ISE 2.0 以降でサポートされています。
開かれたファイルの完全なパスを指定する文字列を取得する読み取り専用プロパティ。
# Shows the full path for the file.
$psISE.CurrentFile.FullPath
IsSaved
Windows PowerShell ISE 2.0 以降でサポートされています。
ファイルが最後に変更された後に保存された場合に $true
を返す読み取り専用のブール型プロパティです。
# Determines whether the file has been saved since it was last modified.
$myfile = $psISE.CurrentFile
$myfile.IsSaved
IsUntitled
Windows PowerShell ISE 2.0 以降でサポートされています。
ファイルにタイトルが与えたことがない場合に $true
を返す読み取り専用プロパティ。
# Determines whether the file has never been given a title.
$psISE.CurrentFile.IsUntitled
$psISE.CurrentFile.SaveAs("temp.txt")
$psISE.CurrentFile.IsUntitled
関連項目
PowerShell