To check whether a file is present

Is there any function / procedure in Pascal program that can help me to check whether a file is present or not?

I hate the 'File not found' run-time error and just want to use the program to tell me the file is not present and then I can continue to
run the program without being thrown out.

Comments

  • : Is there any function / procedure in Pascal program that can help me to check whether a file is present or not?
    :
    : I hate the 'File not found' run-time error and just want to use the program to tell me the file is not present and then I can continue to
    : run the program without being thrown out.
    :
    You can use the $I compiler directive in combination with IOResult() for that. See the help file on IOResult of an example.
  • : : Is there any function / procedure in Pascal program that can help me to check whether a file is present or not?
    : :
    : : I hate the 'File not found' run-time error and just want to use the program to tell me the file is not present and then I can continue to
    : : run the program without being thrown out.
    : :
    : You can use the $I compiler directive in combination with IOResult() for that. See the help file on IOResult of an example.
    :
    [code]
    function fileexists(s:string):boolean;
    var
    stream:file of byte;
    begin
    assign(stream,s);
    {$I-}
    reset(stream);
    {$I+}
    close(stream);
    fileexists:=true;
    if ioresult<>0 then fileexists:=false;
    end;
    [/code]

    ****************

    [b][blue]GAASHIUS[/blue][/b]


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories