필터 지우기
필터 지우기

Compiled Location of Data Files

조회 수: 1 (최근 30일)
Paul Huter
Paul Huter 2012년 12월 11일
I have a compiled "program" (GUI) that relies on data files. However, to get the progbram to read the data files, I need to include them in the compile. I am using an fopen() on the data file, but if it is not included in the compile, the files are not found. I would like to not have to include the files, as they change pretty regularly and I do not want to have to recompile each time.

채택된 답변

Walter Roberson
Walter Roberson 2012년 12월 11일
The current directory of a compiled executable is not what you might expect. If you specify the full directory of the files when you fopen() then it should be able to find them.
  댓글 수: 3
Image Analyst
Image Analyst 2012년 12월 11일
Like Walter said, you don't. Don't store the data files where the executable was deployed because that's not the real executable. The real executable is in a different folder - one you wouldn't expect. The executable you're seeing is more like a self-extracting archive and it unpacks the real executable plus a bunch of other files to some secret folder. You're far, far better off storing your data files in some known folder, like in c:\ProgramData\MATLAB\YOUR_GUI or wherever. Then use fullfile() and exist() to check for them. You can store the last folder you looked to for those files in a mat file if you want, then you can read that upon startup to initialize the data folder to the last folder you used.
Paul Huter
Paul Huter 2012년 12월 11일
Got it! Thank you.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by