How to get the user's installation path in my app designer?
38 次查看(过去 30 天)
显示 更早的评论
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?
回答(1 个)
Rik
2021-6-2
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 个评论
Rik
2021-6-5
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!