Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Finding a file deployed in the appx, for Windows store


This question is answered.


Permlink Replies: 6 - Last Post: Jul 20, 2017 3:41 AM Last Post By: Francisco Peris
Francisco Peris

Posts: 91
Registered: 1/5/15
Finding a file deployed in the appx, for Windows store  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 20, 2017 1:29 AM
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

Francisco Peris

Posts: 91
Registered: 1/5/15
Re: Deployment a file in the appx, for Windows store  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 20, 2017 2:20 AM   in response to: Francisco Peris in response to: Francisco Peris
I have been checking all the possible locations to open the file:

http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Standard_RTL_Path_Functions_across_the_Supported_Target_Platforms

and none works...

I begin to be worried....
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: Deployment a file in the appx, for Windows store  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 20, 2017 2:27 AM   in response to: Francisco Peris in response to: Francisco Peris
Francisco Peris wrote:

I have been checking all the possible locations to open the file:

http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Standard_RTL_Path_Functions_across_the_Supported_Target_Platforms

and none works...

I begin to be worried....

You have to use a full pathname for LoadFromfile, and a file in the
folder returned by TPath.GetDocumentsPath should be visible to your
application since this is a location under the current user's profile.


--
Peter Below
TeamB

Francisco Peris

Posts: 91
Registered: 1/5/15
Re: Deployment a file in the appx, for Windows store  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 20, 2017 2:32 AM   in response to: Francisco Peris in response to: Francisco Peris
Thanks for your answer...

but what I want to open is a file that is deployed with the appx.

So the file is in WindowsApp....... when the appx is installed.

No one of the listed options in embarcadero's website can access that location.
Francisco Peris

Posts: 91
Registered: 1/5/15
Re: Finding a file deployed in the appx, for Windows store  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 20, 2017 3:20 AM   in response to: Francisco Peris in response to: Francisco Peris
I continue adding more info:

If I use GetCurrentDir to find where it is installed the app, to locate that file I have to read, it works well with a Win32 app. However, with an appx, it always return C:\WINDOWS\system32.

So I cannot find the Directory name...it is a complex name with seems to have random letters.


System.IOUtils.TDirectory.GetCurrentDirectory does not work either, returns C:\WINDOWS\system32 as well

Antonio Estevez

Posts: 665
Registered: 4/12/00
Re: Deployment a file in the appx, for Windows store
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 20, 2017 3:29 AM   in response to: Francisco Peris in response to: Francisco Peris
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);
Francisco Peris

Posts: 91
Registered: 1/5/15
Re: Finding a file deployed in the appx, for Windows store  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 20, 2017 3:41 AM   in response to: Francisco Peris in response to: Francisco Peris
Yes, that works. Thanks a lot

meanwhile, I found another way: ExtractFilePath(ParamStr(0))
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02