FileSystem.FileExists(String) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Retourne True si le fichier spécifié existe.
public:
static bool FileExists(System::String ^ file);
public static bool FileExists(string file);
static member FileExists : string -> bool
Public Shared Function FileExists (file As String) As Boolean
Paramètres
- file
- String
Nom et chemin d’accès du fichier.
Retours
Retourne True si le fichier existe ; sinon, cette méthode retourne False. Cette méthode retourne False également si le paramètre représente le chemin d’accès d’un répertoire plutôt qu’un fichier.
Exceptions
Le nom du fichier se termine par une barre oblique inverse (\).
Exemples
Cet exemple vérifie si le fichier Check.txt existe ou non et fournit les informations dans une boîte de message.
If My.Computer.FileSystem.FileExists("c:\Check.txt") Then
MsgBox("File found.")
Else
MsgBox("File not found.")
End If
Remarques
Si l’application ne dispose pas des autorisations suffisantes pour lire le fichier spécifié, la FileExists méthode retourne False, indépendamment de l’existence du chemin d’accès ; la méthode ne lève pas d’exception.