How to get the path of the resource file folder of a packaged app
9 次查看(过去 30 天)
显示 更早的评论
Hi,
I'm trying to create a simple app that copy a default excel file from his resource folder to a folder selected by the user,
I've inserted the excel file in "shared resources and helper files" while packagine the app and it works because fhe file is in the higlighted (in the screenshot) folder afther the installation of the app.
The problem is that I can find a way to access that file (attached there's the code that works when I run the app from the App Designer, but fails when called from the app bar afther the installation),
so that's my question:
Is there a function in Matlab that returns the resource files folder path (the one higlighted in the photo) of the current application?
Is there another way to get that path?
I don't want to copy that path myself because I had to share this application and I suppose that Windows or Linux store those file in different locations
Thanks!
That's my code:
(displaySystemMessage is a function that I had defined to display messages on a textView)
function PasteDefaultExcelSheetButtonPushed(app, event)
errorFound = false;
try
defaultExcelPath = "Default Excel Input.xlsm";
selectedFolderPath = uigetdir();
copyfile(defaultExcelPath, selectedFolderPath);
catch error
errorFound = true;
app.displaySystemMessage("ERRORE", [error.identifier, newline, error.message]);
end
if ~errorFound
app.displaySystemMessage('STATUS', ['Default Excel File Copied from:', newline, defaultExcelPath]);
end
end
That's the screenshot:
(higlighted the folder that I want to access)
0 个评论
回答(1 个)
Simone Parisotto
2020-12-2
Hi!
you can try the following:
rootSettings = matlab.internal.getSettingsRoot;
addonFolder = rootSettings.matlab.addons.InstallationFolder.ActiveValue;
executableFolder = fullfile(addonFolder,'Apps',name_of_your_app);
Hope it helps!
Simone
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!