Check that file exists: Difference between revisions

Added Delphi example
(→‎{{header|Ruby}}: Clarify meaning of File.exists?. The previous edit had stopped using File.exists? and started using File.file? and File.directory?.)
(Added Delphi example)
Line 338:
verify(sep ~ "docs");
}</lang>
 
=={{header|Delphi}}==
<lang Delphi>program EnsureFileExists;
 
{$APPTYPE CONSOLE}
 
uses
SysUtils;
 
begin
if FileExists('input.txt') then
Writeln('File "input.txt" exists.')
else
Writeln('File "input.txt" does not exist.');
 
if FileExists('\input.txt') then
Writeln('File "\input.txt" exists.')
else
Writeln('File "\input.txt" does not exist.');
 
if DirectoryExists('docs') then
Writeln('Directory "docs" exists.')
else
Writeln('Directory "docs" does not exists.');
 
if DirectoryExists('\docs') then
Writeln('Directory "\docs" exists.')
else
Writeln('Directory "\docs" does not exists.');
end.</lang>
 
=={{header|E}}==
Anonymous user