>The files that have this problem are all old, possibly from the 1980s,
>but definitely not from 1979. Is there a special meaning for
>FileInfo.time = 0? 

Setting the time zero under DOS was a way to have the file show
no timestamp.

>I thought I could fix the problem by setting the dates to something
>later - maybe 1/1/1981? 
>I used 
> NewDate := DateTimeToFileDate(StrToDate('1/1/1981'));
> WinError := FilesetDate(Handle,Newdate);
>
>I get error 6, invalid handle. This is using the same handle that
>FindFirstFile gave me along with a valid FindData record a few lines
>before. Why is there now an error on setting the date?

I think you are confusing handles. FindFirstFile returns a file search
handle, not an opened file handle. FileSetDate works on an open
file which has been opened with FileOpen.

Glenn Lawler
www.incodesystems.com



-----Original Message-----
From:   tim11g [SMTP:[email protected]]
Sent:   Wednesday, February 25, 2009 11:56 AM
To:     [email protected]
Subject:        [delphi-en] Understanding different behavior with FindFirstFile 
and FindFirst

I have some old code (dating back to Delphi 1 or maybe even BP days)
that performs a recursive scan of a disk volume, and returns a Tlist
full of objects representing each file. 

Some newer code uses that data and does some further work. One of the
checks verifies that the file is present.

Bottom line, I have some files that are found with FindFirst, but are
not found by FileExists. I'm trying to understand why. 

When matchstring is 'Q:\SOME\LONG\PATH\SOMEFILE.TXT',
FindFirst (matchstring, FAAnyFile or FADirectory, FileInfo);
succeeds and provides a valid TSearchRec into FileInfo. 

A few lines later the same program I can call FileExists(matchstring),
and it will return False. 
FileExists calls FileAge to determine if a file exists. FileAge
returns -1 for this file. 

Digging deeper, FindFirstFile(PChar(matchstring), FindData) returns 
ftLastWriteTime as part of the FindData record. The value of
ftLastWriteTime is 12/31/1979 11:27:32 PM


Opening the same file with FindFirst (matchstring, FAAnyFile or
FADirectory, FileInfo), FileInfo.time is set to 0. 

The files that have this problem are all old, possibly from the 1980s,
but definitely not from 1979. Is there a special meaning for
FileInfo.time = 0? 

I thought I could fix the problem by setting the dates to something
later - maybe 1/1/1981? 
I used 
 NewDate := DateTimeToFileDate(StrToDate('1/1/1981'));
 WinError := FilesetDate(Handle,Newdate);

I get error 6, invalid handle. This is using the same handle that
FindFirstFile gave me along with a valid FindData record a few lines
before. Why is there now an error on setting the date?

Am I approaching this wrong? 

Reply via email to