It is perfectly normal to open and change an existing ini file: Program Test;
{$mode objfpc} {$h+} uses sysutils, inifiles; var F: TIniFile; Path: String; Value1, Value2: String; begin Path := 'test.ini'; F := TIniFile.Create(Path); if ParamCount > 0 then Value1 := ParamStr(1) else Value1 := 'Value_1'; if ParamCount > 1 then Value2 := ParamStr(2) else Value2 := 'Value_2'; Try F.WriteString('Section','Item_1',Value1); F.WriteString('Section','Item_2',Value2); Finally F.Free; end; end. bart@simenon:~/LazarusProjecten/ConsoleProjecten> fpc test.pp Free Pascal Compiler version 2.4.2 [2010/11/08] for i386 Copyright (c) 1993-2010 by Florian Klaempfl Target OS: Linux for i386 Compiling test.pp Linking test 23 lines compiled, 0.8 sec bart@simenon:~/LazarusProjecten/ConsoleProjecten> ./test bart@simenon:~/LazarusProjecten/ConsoleProjecten> cat test.ini [Section] Item_1=Value_1 Item_2=Value_2 bart@simenon:~/LazarusProjecten/ConsoleProjecten> ./test One Two bart@simenon:~/LazarusProjecten/ConsoleProjecten> cat test.ini [Section] Item_1=One Item_2=Two Now I make the file test.ini read-only: bart@simenon:~/LazarusProjecten/ConsoleProjecten> chmod -w test.ini bart@simenon:~/LazarusProjecten/ConsoleProjecten> ./test One_One Two_Two An unhandled exception occurred at $08082182 : EFCreateError : Unable to create file "test.ini" $08082182 $0808A223 $0807AC8E $0807AD48 $080481F3 And, as expected, creating the file (with write permissions), fails. And, changing it back again to read-write access resolves the problem: bart@simenon:~/LazarusProjecten/ConsoleProjecten> chmod +w test.ini bart@simenon:~/LazarusProjecten/ConsoleProjecten> ./test One_One Two_Two bart@simenon:~/LazarusProjecten/ConsoleProjecten> cat test.ini [Section] Item_1=One_One Item_2=Two_Two Bart On 3/15/11, leledumbo <leledumbo_c...@yahoo.co.id> wrote: > Weird, I never had such a problem. In fact, one of my application uses it > (the others use it implicitly via TIniPropStorage). The only problem I can > think of is somehow the file is opened as well by another code and isn't > closed. What if you try to debug using gdb so that you can see exactly where > it fails. > > -- > View this message in context: > http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Unable-to-rewrite-ini-file-which-exists-error-unable-to-create-ini-file-need-to-rewrite-it-tp2680589p2681987.html > Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com. > > -- > _______________________________________________ > Lazarus mailing list > Lazarus@lists.lazarus.freepascal.org > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > -- _______________________________________________ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus