Newsgroups : Borland : borland.public.delphi.rtl.win32 : 2005 Apr : Weird problem with FileExists()...

www.cryer.info
Managed Newsgroup Archive

Weird problem with FileExists()...

Subject:Weird problem with FileExists()...
Posted by:"Adrien Reboisson" (adrien-reboissonatastasedotcom@nospam.com)
Date:29 Apr 2005 07:15:10

Hi,

I'm currently developping an application with D7 and I try to test it on a lot of different computers and configurations. Today I tested it on a Win XP Pro (SP1, French Edition) with abnormal results. After a hard debug party on the computer where there was the problem I discovered that FileExists() returned false *even if* the file existed on the hard drive. Amazing. I think I've used FileExists about one billon times in a lot of different projects without encountering any problem...

The VCL use the result of the Win API FileAge() in order to determine if the file exists or not. So I decided to use another method (with a TSeachRec) and to replace in my project  all the calls of FileExists() by my proc :

function MyFileExistsProc(const AFilePath: string): Boolean;
var
  Sr: TSearchRec;
begin
  Result := FindFirst(AFilePath, faAnyFile, Sr) = 0;
  if Result then
    FindClose(Sr);
end;

And... it worked !

I'm a little bit puzzled. Where does the problem come from ?? Me, the VCL, Windows ?... Any hints GREATLY appreciated :-)

Best regards,

Adrien Reboisson

Replies:

www.cryer.info
Managed Newsgroup Archive