Funny thing is that in the example i'm quoting from i forced to use Application.exename and changing extension to xml
(i changed it to force it to use another path).
It shows the basic usage. It is some silly buttons and labels that get stored, restored and changed (not important unless you wish to know more, just say so and i post complete project).
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls, XMLPropStorage;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
XButton1: TButton;
XButton2: TButton;
XButton3: TButton;
XButton4: TButton;
Button3: TButton;
XLabel1: TLabel;
XLabel2: TLabel;
XLabel3: TLabel;
XLabel4: TLabel;
Panel1: TPanel;
XMLPropStorage1: TXMLPropStorage;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure XMLPropStorage1RestoreProperties(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
// SaveSettings
XMLPropStorage1.Save;
Button1.Enabled := False;
Button2.Enabled := True;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Button2.Enabled := False;
Button3.Enabled := True;
// Simulate action
XButton1.Hide;
XButton2.Hide;
XButton3.Hide;
XButton4.Hide;
XButton1.Caption := 'This is button 1';
XLabel1.Caption := 'changed';
XLabel2.Color:= clRed;
XLabel1.Caption := 'changed';
XLabel2.Color:= clGreen;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
// LoadSettings
XMLPropStorage1.Restore;
Button2.Enabled := True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
XMLPropStorage1.FileName := 'G:\Temp\SomeFileStorage.xml';
// initialize 'action' buttons
Button1.Enabled := True;
Button2.Enabled := False;
Button3.Enabled := False;
end;
end.
That worked for me and should work the way you want to, by changing:
XMLPropStorage1.FileName := 'G:\Temp\SomeFileStorage.xml';
into
XMLPropStorage1.FileName := GetAppConfigDir(False)+'SomeFileName';
As said in my previous post, make sure that the path that GetAppConfigDir returns actually exist.
In case you still have issues then please describe them and also state lazarus and fpc version that you are using.