Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2007 May : FileExists but The system cannot find the file specified
| Subject: | FileExists but The system cannot find the file specified |
| Posted by: | "Confused of Worthing" (no..@none.none) |
| Date: | 3 May 2007 07:56:12 |
Simple code for demo:
procedure TForm1.Button1Click(Sender: TObject);
const
MY_INI = 'C:\Test.ini';
begin
if writeprivateprofilestring('Section','Ident','Value',MY_INI) then
if FileExists(MY_INI) then
if not writeprivateprofilestring(nil, nil, nil, MY_INI) then
Caption := SysErrorMessage(GetLastError);
end;
The first call to writeprivateprofilestring and the FileExists call both return TRUE, as expected. The second call to writeprivateprofilestring returns FALSE and the form caption is set = The system cannot find the file specified. This is puzzling me. How come the file exists but the system cannot find it?