I use Delphi 1 (Old, I know) and have a problem:
Before I load a file using the LoadFrom File method I want to check if it exists in the local directory. How can I do it?
If I'm right in later versions of Delphi you can use : if exist .... but not so in Delphi 1
Thanks in advance
Mark
--
M.J. de Vries
Delete GEEN.SPAM when replying
Here's what I use but note that you need the "I" compiler switch set to the
"old" way of doing things and the use of "string" (Pascal style, leading
length byte) as a parameter.
{$I+}
function file_exists(s : string) : boolean;
var
n : file;
f : boolean;
begin
assignfile(n,s);
reset(n);
f := ioresult = 0;
closefile(n);
file_exists := (ioresult = 0) and f;
end;
{$I-}
Mark de Vries wrote in message <6q6enh$rlt$1...@sun4000.casema.net>...
Paul J. Poirier <p...@istar.ca> wrote in article
<6SAx1.1$167....@NewsRead.Toronto.iSTAR.net>...
In article <6q6enh$rlt$1...@sun4000.casema.net>, Mark de Vries <mdevries@GE
EN.SPAM.casema.net> writes
>Hi,
>
>I use Delphi 1 (Old, I know) and have a problem:
>Before I load a file using the LoadFrom File method I want to check if it exists
>in the local directory. How can I do it?
>If I'm right in later versions of Delphi you can use : if exist .... but not so
>in Delphi 1
>
>Thanks in advance
>
>Mark
>
--
Ian A. Newby
Just use FileExists()...
If FileExists(ExtractFilePath(Application.ExeName) + 'Test.Txt') then
{ File is there }
Works in all versions of Delphi.
Ken
--
Ken White
kwh...@westelcom.com
Clipper Functions for Delphi
http://members.aol.com/clipfunc/
Mark de Vries wrote:
>
> Hi,
>
> I use Delphi 1 (Old, I know) and have a problem:
> Before I load a file using the LoadFrom File method I want to check if it exists in the local directory. How can I do it?
> If I'm right in later versions of Delphi you can use : if exist .... but not so in Delphi 1
>
> Thanks in advance
>
> Mark
>
> --