Is there anyway to get the folder location where the executable is running ?

14 ビュー (過去 30 日間)
Saurabh PATIL
Saurabh PATIL 2013 年 10 月 16 日
回答済み: Stefanie Schwarz 2024 年 10 月 21 日
I want to create an executable which grabs files in the same directory where the executable is running and process it accordingly . I used in the code 'pwd' command to get the current folder location, but when the executable is created Matlab hardcodes the current folder location of my working directory and packages it .Thus i am not able to deploy my tool .

回答 (3 件)

Adam Filion
Adam Filion 2013 年 10 月 16 日
I wouldn't expect it to hardcode that path at compile time which could be a bug. You may want to contact tech support to confirm that.
Alternatively you could use dir to identify files, or if you want to make it interactive use uigetfile / uigetdir.

Image Analyst
Image Analyst 2013 年 10 月 16 日
編集済み: Image Analyst 2013 年 10 月 16 日
I believe it's in the system variable called ctfroot.
root = ctfroot returns a string that is the name of the folder where the CTF file for the deployed application is expanded.
  2 件のコメント
Saurabh PATIL
Saurabh PATIL 2013 年 10 月 16 日
I tried using this but it did'nt work. I also used
[status, wrkdir] = dos('echo %cd%'); cd wrkdir;
but that also creates a path in the executable .
Image Analyst
Image Analyst 2013 年 10 月 16 日
編集済み: Image Analyst 2013 年 10 月 16 日
cd or pwd is not a reliable and robust way of getting the folder of the executable since the current folder may be changed by code within the executable. Then you might try mfilename('fullpath').

サインインしてコメントする。


Stefanie Schwarz
Stefanie Schwarz 2024 年 10 月 21 日

カテゴリ

Help Center および File ExchangeMATLAB Compiler についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by