How to get the path of the resource file folder of a packaged app

22 visualizaciones (últimos 30 días)
Pietro Ungar
Pietro Ungar el 9 de Feb. de 2020
Respondida: Simone Parisotto el 2 de Dic. de 2020
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)

Respuestas (1)

Simone Parisotto
Simone Parisotto el 2 de Dic. de 2020
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

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by