In compiled app, "pwd" is returning Matlab code directory rather than application .exe directory. Why and how can I fix this?

조회 수: 35 (최근 30일)
I have a compiled application that needs to load a settings file. I'm using "pwd" to get the current program working directory, but instead of returning the compiled application directory ('C:\Programs\Singulex\{appname}') it is returning the code directory instead. It is as if the compiler evaluates "pwd" during compile time and sticks that into the code. I've tried setting the application directories to 'C:\Programs\Singulex\{appname}' in the compiler application project, but that doesn't affect this.
  댓글 수: 1
Thomas
Thomas 2020년 4월 3일
This is very confusing, but this is what works for me with R2019b.
Files bundled with your compiled app under "Files installed for your end user" are installed in the installation directory ("C\Program Files\{appname}\application"). You can find this folder using getenv('ProgramFiles'), and this will work as long as user installs in the default directory.
Files bundled with your compiled app under "Files required for your application to run" are installed in the ctfroot directory. However, for me, it is not installed there, but in a subfolder, and the name of the folder is a substring of the application name. You can use this if you see what the name of this subfolder is and hard code it, or write some code to look for the correct directory name dynamically.
So you have two options, but neither is bulletproof.
If I am doing it wrong, I would be overjoyed to have my ignorance and incompetence exposed!

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

채택된 답변

Walter Roberson
Walter Roberson 2016년 6월 23일

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by