ISEFileCollection オブジェクトは、ISEFile オブジェクトのコレクションです。PowerShellTab オブジェクトに関連付けられているファイル コレクションは、このクラスのメンバーです。$psISE.CurrentPowerShellTab.Files コレクションもその 1 つです。

メソッド

Add()

無題のファイルを新規作成して返し、コレクションに追加します。新たに作成されたファイルの IsUntitled プロパティは true になります。

# Adds a new file to the collection of files in the current PowerShell tab.
$newFile = $psISE.CurrentPowerShellTab.Files.Add() 
# Add the date as the first line of text in the new file.
$newFile.Editor.Text = "#" + (Get-Date) 

Add(string fullPath)

fullPath パラメーターで指定されたファイルをファイルのコレクションに追加します。新たに作成されたファイルの IsUntitled プロパティは false になります。

注意事項:

完全なパスではなく、相対パスやファイル名のみが指定された場合、例外がスローされます。

fullpath
ファイルの完全なパス。

# Adds the file specified by its fullpath to the collection of files in the current PowerShell tab.
$psISE.CurrentPowerShellTab.Files.Add("$pshome\Examples\profile.ps1")

Remove(Microsoft.PowerShell.Host.ISE.ISEFile file)

現在の PowerShell タブから指定されたファイルを削除します。

file
コレクションから削除する ISEFile。ファイルが保存されていない場合は、例外がスローされます。未保存のファイルを強制的に削除するには、次のオーバーライドを使用します。

# Removes the first opened file from the file collection associated with the current PowerShell tab.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.Remove($firstfile)

Remove(Microsoft.PowerShell.Host.ISE.ISEFile file, bool force)

現在の PowerShell タブから指定されたファイルを削除します。

file
コレクションから削除する ISEFile。

force
未保存のファイルを強制的に削除してもよいかどうかを示すブール型パラメーター。

# Removes the first opened file from the file collection associated with the current PowerShell tab.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.Remove($firstfile, $true)

SetSelectedFile(Microsoft.PowerShell.Host.ISE.ISEFile selectedFile)

selectedFile パラメーターで指定されたファイルを選択します。

selectedFile
選択する ISEFile。

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

関連項目




目次