[Lazarus] Unable to rewrite .ini file which exists... error unable to create .ini file. (need to rewrite it).

Sven Barth pascaldragon at googlemail.com
Tue Mar 15 14:54:08 CET 2011


Am 15.03.2011 12:45, schrieb Bart:
> On 3/15/11, Peter Williams<pewilliams2010 at live.com>  wrote:
>
>> ConfigIni := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
>
> You really should not do that in most OS's, even on Windows it is
> deprecated since win9x.
> Most times you will not have write permissions there.
> Also under *nix this location might not be what you expect it to be...
>
> Use GetAppConfigDir to determine where to put INI files.

It took me a while until I understand what you wanted to tell... maybe 
you should have mentioned directly that you mean "writing in the 
application's directory".

While I agree with you that modifyable configuration should be put into 
the proper configuration locations I personally see no problem with 
having a readonly configuration file in the application's directory 
(yes, I'm aware that this is not cross platform). So the problem could 
be that the INI file is always opened as "read/write", while at the 
beginning "read" should be sufficient. This could explain why 
TMemIniFile works for such cases.

Regards,
Sven




More information about the Lazarus mailing list