ISEFileCollection 物件
ISEFileCollection 對像是 ISEFile 物件的 集合。 範例是 $psISE.CurrentPowerShellTab.Files
集合。
方法
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] - 選擇性的 Boolean 如果設定為 $true
,即使檔案在上次使用之後尚未儲存,也會授與移除檔案的許可權。 預設值為 $false
。
# Removes the first opened file from the file collection associated with the current PowerShell tab.
# If the file has not 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 has not been saved.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.Remove($firstfile, $true)
SetSelectedFile(selectedFile )
Windows PowerShell ISE 2.0 和更新版本支援。
選取由 selectedFile 參數 指定的檔案。
SelectedFile - Microsoft.PowerShell.Host.ISE.ISEFile 您要選取的 ISEFile 檔案。
# Selects the specified file.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.SetSelectedFile($firstfile)
另請參閱
- ISEFile 物件
- Windows PowerShell ISE 腳本物件模型的 用途
- ISE 物件模型階層