次の方法で共有


ISEFileCollection オブジェクト

ISEFileCollectionオブジェクトはISEFileオブジェクトの集合です。 例として $psISE.CurrentPowerShellTab.Files コレクションがあります。

Methods

Add( [FullPath] )

Windows PowerShell ISE 2.0以降でサポートされています。

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

  • [FullPath] - オプション文字列 - ファイルの完全に指定されたパス。 FullPathパラメータと相対パスを含める場合、またはフルパスの代わりにファイル名を使う場合に例外が生成されます。
# Adds a new untitled file to the collection of files in the current PowerShell tab.
$newFile = $psISE.CurrentPowerShellTab.Files.Add()

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

Remove( File, [Force] )

Windows PowerShell ISE 2.0以降でサポートされています。

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

ファイル - 文字列 コレクションから削除したいISEFileファイル。 ファイルが保存されていない場合、このメソッドは例外をスポールします。 Force Switchパラメータを使って、保存されていないファイルの強制削除を強制します。

[Force] - オプションのブール値 $trueに設定した場合、最後の使用後に保存されていなくてもファイルを削除する権限を与えます。 既定値は $falseです。

# Removes the first opened file from the file collection associated with the current
# PowerShell tab.  If the file hasn't yet been saved, then an exception is generated.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.Remove($firstfile)

# Removes the first opened file from the file collection associated with the current
# PowerShell tab, even if it hasn't been saved.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.Remove($firstfile, $true)

SetSelectedFile( selectedFile )

Windows PowerShell ISE 2.0以降でサポートされています。

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

SelectedFile - Microsoft.PowerShell.Host.ISE.ISEFile を選択したいファイル。

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

こちらもご覧ください