How can I get the folder where the standalone application (.exe) is installed in order to access additional files located there too.
Afficher commentaires plus anciens
Running the standalone program the current folder is the desktop-folder or can be chosen by the link properties as working directory. But my help-files are located in the same directory as the exe-file but this is unknown for me and I don't want to search the full hard-disk.
Réponses (3)
Image Analyst
le 5 Août 2014
Modifié(e) : Image Analyst
le 5 Août 2014
4 votes
Read the FAQ: http://matlab.wikia.com/wiki/FAQ#What_is_the_path_in_my_deployed_application.3F. Sorry, I know it's complicated but that's the way it is.
It's a lot more complicated than just saying ctfroot. ctfroot is not where your executable is. And the "current" folder is not necessarily where your executable is, or where ctfroot is, or where matlabroot is. There are a bunch of folders, some/most of which I go over in the attached demo. Read over the attached file's comments. Then compile the application and put the created executable somewhere (in some folder where you want it to be installed). Then run it and find out some things, some of which are surprising.
There are also some things you will learn in there about shipping files with your app - where they need to go and how you need to refer to them (their filename) to access them.
1 commentaire
Lothar
le 6 Août 2014
Stefanie Schwarz
le 21 Oct 2024
0 votes
See also:
How can I find the directory containing my compiled application?
1 commentaire
Stéphane Issartel
le 15 Sep 2025
Here is a solution for Windows OS (using .NET)
if (isdeployed())
% Use .NET to find the name of the .exe
appDir = System.Diagnostics.Process.GetCurrentProcess();
appDir = char(appDir.MainModule.FileName);
appDir = fileparts(appDir);
else
% Use path of .m file if not compiled
appDir = mfilename('fullpath');
appDir = fileparts(appDir);
end
Catégories
En savoir plus sur MATLAB Compiler dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!