Start Free Trial
Log in
mikeTmike
asked on
File Checking
I need to know how to check if a file exists.
ASKER CERTIFIED SOLUTION
dbrunton
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
How it works
Start Free Trial
anasexpert
function FileExists(FileName: string) : Byte;
var
f: file;
begin
{$I-}
Assign(f, FileName);
Reset(f);
case IOResult of
2:FileExists :=2;
3:FileExists :=3;
else FileExists :=0;
end;{end case}
{$I+}
Close(f);
end;
begin
case FileExists(ParamStr(1)) of
2: Writeln('Flle exists) ;
3: Writeln('Path not found');
0: Writeln('Path not found');
end;
end.
var
f: file;
begin
{$I-}
Assign(f, FileName);
Reset(f);
case IOResult of
2:FileExists :=2;
3:FileExists :=3;
else FileExists :=0;
end;{end case}
{$I+}
Close(f);
end;
begin
case FileExists(ParamStr(1)) of
2: Writeln('Flle exists) ;
3: Writeln('Path not found');
0: Writeln('Path not found');
end;
end.