How to get the user's installation path in my app designer?
56 views (last 30 days)
Show older comments
When I use app designer, I want to create some folder in the installation path when someone is using my app. How can I get the installation path where my app is installed?
For example, someone installs my app in 'C:\Program Files\myapp', I want to create a folder in this path to save some compute results. How can I get this installation path when I am coding by app designer?
3 Comments
Answers (1)
Rik
on 2 Jun 2021
If you want more control over where your persistent files are stored, I would suggest the GetWritableFolder.
This will generate a path that is persistent across versions of Matlab and across calls. This is what I currently use if I want to persistently store configurations.
f=GetWritableFolder('ForceStatus',1);
6 Comments
Rik
on 5 Jun 2021
It does have to do with privileges. If the user installs your app as admin (and puts it in a location where you need admin privileges to write), and then runs your app as a normal user, you're stuck. If you use my function you are guaranteed the same path every time, and you should have write access as any user.
I don't know if there is a function that will return the installation folder (maybe matlabroot gets modified?), but you shouldn't be using that anyway. The %APPDATA% folder shortcut exists for a reason.
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!