Description |
Returns true if the file specified in PathString exists, otherwise false.
|
|
Microsoft MSDN Links |
System.IO
System.IO.File
|
|
|
A simple example |
program Project1;
{$APPTYPE CONSOLE}
uses
System.IO;
var
Path : String;
Writer : StreamWriter;
begin
// Create a text file
Path := 'C:\DelphiBasics.txt';
Writer := System.IO.File.CreateText(Path);
// Close the file
Writer.Close;
if System.IO.File.Exists(Path)
then Console.WriteLine('File exists')
else Console.WriteLine('File does not exist');
// Now delete this file
Console.WriteLine;
Console.WriteLine('Deleting the file :');
Console.WriteLine;
System.IO.File.Delete(Path);
if System.IO.File.Exists(Path)
then Console.WriteLine('File exists')
else Console.WriteLine('File does not exist');
Console.Readline;
end.
| Show full unit code | File exists
Deleting the file :
File does not exist
|
|
|
|