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!