FileSystem.FileExists(String) Metoda

Definice

Vrátí True , pokud zadaný soubor existuje.

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

Parametry

file
String

Název a cesta k souboru.

Návraty

Vrátí True , pokud soubor existuje; jinak tato metoda vrátí False. Tato metoda také vrátí False , pokud parametr představuje cestu adresáře místo souboru.

Výjimky

Název souboru končí zpětným lomítkem (\).

Příklady

Tento příklad zkontroluje, jestli soubor Check.txt existuje a obsahuje informace v poli se zprávou.

If My.Computer.FileSystem.FileExists("c:\Check.txt") Then
    MsgBox("File found.")
Else
    MsgBox("File not found.")
End If

Poznámky

Pokud aplikace nemá dostatečná oprávnění ke čtení zadaného souboru, FileExists metoda vrátí False, bez ohledu na existenci cesty; metoda nevyvolá výjimku.

Platí pro