Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find if a file exists?

Status
Not open for further replies.

MizardX

Programmer
Mar 27, 2003
1
SE
How do i find if a file exists? I'm using Turbo Pascal 7... i couldn't find anything in the help-index that resembles "File existance" [neutral]
 
Try this:
Code:
function fileExists(fname: String): boolean;                                  
var                                                                           
   f: file of byte;
                                                                   
begin                                                                         
   Assign(f,fname);                                                           
   {$I-}                                                                      
   Reset(f);                                                                  
   {$I+}                                                                      
      if (IOResult = 0) then
      begin
         close(f);
         fileExists:=true;
      end
      else
         fileExists:=false;                                                  
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top