FileSystemProxy.FileExists(String) Metoda

Definice

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

public:
 bool FileExists(System::String ^ file);
public bool FileExists(string file);
member this.FileExists : string -> bool
Public 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.

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

Viz také