How can I get the folder where the standalone application (.exe) is installed in order to access additional files located there too.

조회 수: 24 (최근 30일)
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.

답변 (3개)

Image Analyst
Image Analyst 2014년 8월 5일
편집: Image Analyst 2014년 8월 5일
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
Lothar
Lothar 2014년 8월 6일
Great link and a lot of readings as well as a broken link to an important text. Sorry I failed to realize the ideas I've got. See my comments to Sean de Wolski

댓글을 달려면 로그인하십시오.


Sean de Wolski
Sean de Wolski 2014년 8월 5일
  댓글 수: 1
Lothar
Lothar 2014년 8월 6일
In principle this way seems to be good but it refers to the temp-location of the CTF and my additional files that are to be installed with the application are in the application folder besides the exe-file. mcc works still with the -C option and I don't know how to pass additional parameters to mcc in the compiler app dialogue to force the CTF into the application folder. Done this ctfroot would be great.

댓글을 달려면 로그인하십시오.


Stefanie Schwarz
Stefanie Schwarz 2024년 10월 21일
  댓글 수: 1
Stéphane Issartel
Stéphane Issartel 2025년 9월 15일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Standalone Applications에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by