FileSystem.FileExists(String) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns True
if the specified file exists.
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
- file
- String
Name and path of the file.
Returns True
if the file exists; otherwise this method returns False
. This method also returns False
if the parameter represents the path of a directory rather than a file.
The name of the file ends with a backslash (\).
This example checks to see whether or not the file Check.txt
exists and supplies the information in a message box.
If My.Computer.FileSystem.FileExists("c:\Check.txt") Then
MsgBox("File found.")
Else
MsgBox("File not found.")
End If
If the application does not have sufficient permissions to read the specified file, the FileExists
method returns False
, regardless of the existence of the path; the method does not throw an exception.
Προϊόν | Εκδόσεις |
---|---|
.NET | Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET σχόλια
.NET είναι ένα έργο ανοιχτού κώδικα. Επιλέξτε μια σύνδεση για να παρέχετε σχόλια: