L'objet ISEFileCollection est une collection d'objets ISEFile. La collection de fichiers associée à un objet PowerShellTab est un membre de cette classe. Exemple : la collection $psISE.CurrentPowerShellTab.Files.

Méthodes

Add()

Crée et retourne un fichier sans titre et l'ajoute à la collection. La propriété IsUntitled du fichier venant d'être créé a la valeur 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)

Ajoute un fichier spécifié par le paramètre fullPath à la collection de fichiers. La propriété IsUntitled du fichier venant d'être créé a la valeur false.

Remarque :

Cette méthode lève une exception si un chemin d'accès relatif ou un nom de fichier est utilisé au lieu du chemin d'accès complet.

fullpath
Chemin d'accès complet du fichier.

# 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)

Supprime le fichier spécifié de l'onglet PowerShell actif.

file
Objet ISEFile que vous voulez supprimer de la collection. Si le fichier n'a pas été enregistré, cette méthode lève une exception. Utilisez la méthode de substitution suivante pour forcer la suppression d'un fichier non enregistré.

# 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)

Supprime le fichier spécifié de l'onglet PowerShell actif.

file
Objet ISEFile que vous voulez supprimer de la collection.

force
Paramètre booléen qui donne l'autorisation de supprimer le fichier même s'il n'a pas été enregistré depuis sa dernière utilisation.

# 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)

Sélectionne le fichier spécifié par le paramètre selectedFile.

selectedFile
Objet ISEFile que vous souhaitez sélectionner.

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

Voir aussi




Table des matières