> 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.
>
Thanks for the tip, Glenn. A handle is not always a handle!
So now I have:
FileHandle := FileOpen(matchstring,fmOpenRead);
if FileHandle > 0 then begin
NewDate := DateTimeToFileDate(StrToDate('1/1/1981'));
WinError := FilesetDate(FileHandle,Newdate);
Now I get WinError 5 (Access Denied) when I try to change the date.
However, the file is not open or locked.
I can change the file's modified date to 1/1/1981 using a program
called Attribute Changer, so it is possible. I would like to add this
date change to my code so it will automatically fix any "bad dates"
that are found.