How to resolve the algorithm Check that file exists step by step in the Delphi programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Check that file exists step by step in the Delphi programming language

Table of Contents

Problem Statement

Verify that a file called     input.txt     and   a directory called     docs     exist.

This should be done twice:

Optional criteria (May 2015):   verify it works with:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Check that file exists step by step in the Delphi programming language

Source code in the delphi programming language

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.


  

You may also check:How to resolve the algorithm I before E except after C step by step in the Julia programming language
You may also check:How to resolve the algorithm Circles of given radius through two points step by step in the Phix programming language
You may also check:How to resolve the algorithm Jewels and stones step by step in the Modula-2 programming language
You may also check:How to resolve the algorithm Closures/Value capture step by step in the Emacs Lisp programming language
You may also check:How to resolve the algorithm Create an HTML table step by step in the Scheme programming language