Objet ISEFileCollection
L’objet ISEFileCollection est une collection d’objets ISEFile. Par exemple, la collection $psISE.CurrentPowerShellTab.Files
.
Méthode
Add( [FullPath] )
Pris en charge dans Windows PowerShell ISE 2.0 et versions ultérieures.
Crée et retourne un nouveau fichier sans titre et l’ajoute à la collection. La propriété IsUntitled du fichier nouvellement créé est $true
.
[FullPath] - Chaîne facultative Chemin d’accès complet du fichier. Une exception est générée si vous incluez le paramètre FullPath et un chemin relatif, ou si vous utilisez un nom de fichier au lieu du chemin d’accès complet.
# 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] )
Pris en charge dans Windows PowerShell ISE 2.0 et versions ultérieures.
Supprime un fichier spécifié de l’onglet PowerShell actuel.
File - String The ISEFile file that you want to remove from the collection. Si le fichier n’a pas été enregistré, cette méthode lève une exception. Utilisez le paramètre Forcer commutateur pour forcer la suppression d’un fichier non enregistré.
[Force] - booléen facultatif Si défini sur $true
, accorde l’autorisation de supprimer le fichier même s’il n’a pas été enregistré après la dernière utilisation. La valeur par défaut est $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 )
Pris en charge dans Windows PowerShell ISE 2.0 et versions ultérieures.
Sélectionne le fichier spécifié par le paramètre SelectedFile.
SelectedFile - Microsoft.PowerShell.Host.ISE.ISEFile Le fichier ISEFile que vous souhaitez sélectionner.
# Selects the specified file.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.SetSelectedFile($firstfile)