From: mrcope@primenet.com (Mike Copeland) Subject: Re: FileExists Date: 19 Feb 1999 00:00:00 GMT Message-ID: References: <79ugia$9m1$1@hermes.is.co.za> <36CD83AF.B5E7223D@lehmann-consult.de> X-Complaints-To: abuse@globalcenter.net Organization: Copeland Computer Services X-Posted-By: @204.245.27.69 (mrcope) Newsgroups: comp.lang.pascal.borland I've always regarded this particular way of checking for a file's existence both very time-consuming and fraught with potential errors (trying to close an unopened file, neglecting to close the redundantly- opened file before its actual use, etc.). All this can be simplified, sped up, and shortened by using FindFirst. Note that "opening" a file requires multiple system calls, requires the RTL to allocate structures and buffers, and all this must be "undone" at some time. It also runs the risk of exceeding available file handles. Really, it's so much better to use FindFirst or FSearch - and they're somewhat more useful (for finding a file which isn't in the working directory). > sure there is an easy wys to determine if a disk file exists. > try to open this file and ioresult will return you an error, if it doesn't > exist. > source: > function fileexist(name : string) : boolean; > var f : file; > begin > {$I-} assign(f, name); reset(f); {$I+} > if ioresult <> 0 then {error occured > file doesn't exist) > fileexist := false > else begin > close(f); fileexist := true; > end; > end; > i hope i helped you > > > > Is there any simple ways of determining if a disk file exists using TP7 > > (like the Delphi FileExists function).