How can I get the full path of my current *.mlapp file?
50 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mark Golberg
am 15 Jun. 2022
Kommentiert: Mark Golberg
am 19 Jun. 2022
Hi
I'm building a gui via App Designer. I'd like to specify a path of an XML file. I'd like it to be relative to my main *.mlapp file.
Eventually, I'd like to ha ve a general function of the following format:
IF running in StandAlone Mode --> XML file path should be relative to where the exe file recides (when distributed, I'd ask the users to keep this XML file in the same folder as the exe file).
IF running in Developers Mode --> XML file path should be relative to when the *.mlapp file recides.
THANKS!
1 Kommentar
Geoff Hayes
am 16 Jun. 2022
@Mark Golberg - this article https://blogs.mathworks.com/loren/2008/08/11/path-management-in-deployed-applications/ may be useful.
Akzeptierte Antwort
Weitere Antworten (1)
Fangjun Jiang
am 16 Jun. 2022
I think you can implement this in your code.
Search for the .exe file or .mlapp file using exist('', 'file'), use which() and fileparts() to get the root directory. If both exists, pick your priority.
Then, use fullfile() to combine the root directory and folder to specify the full path of the .xml file.
0 Kommentare
Siehe auch
Kategorien
Mehr zu File Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!