El 20/07/2017 a las 10:29, Francisco Peris escribió:
Hi there:
I have to deploy a file, that it is read when app start. I am talking about an appx file, for the Windows store.
So let me summarize what I did:
menu project/deployment
file name = 'ver'; Remote Path = Assets\ or \. (it does not work with these two locations)
when app starts, in form.create... I have to read the file. If I use this code to read the file:
form1.listbox5.Items.LoadFromFile('ver');
It searches the file in C:\WINDOWS\System32\, producing an error.
Could you help me to solve this issue?
Thanks
Set "Remote path" to .\
and load the file like this:
uses
...
System.IOUtils,
...
procedure TForm1.FormCreate(Sender: TObject);
var
FileName: String;
begin
...
FileName:= TPath.Combine(TPath.GetLibraryPath, 'ver');
if TFile.Exists(FileName) then
begin
listbox5.Items.LoadFromFile(FileName);
end;
...
end;
Note: Don't use the global variable Form1 to access properties/methods
from inside methods of its class. Use the 'Self' keyword or nothing:
Self.listbox5.Items.LoadFromFile(FileName);
// or simply
listbox5.Items.LoadFromFile(FileName);
Connect with Us