Additional (configuration) Files in compiled standalone application

조회 수: 2 (최근 30일)
Jette
Jette 2016년 1월 11일
댓글: Jette 2016년 1월 11일
Hello,
I need to write a standalone GUI application using R2010b (specified by customer, I would be happe to use a newer version...).
I would like to include at least one configuration file in Excel format (*.xlsx) to give the user some flexibility to configure the tool (e.g. labels of measurement quantitities which change over time). I would like the user to be able to change this file in place and the tool shall use the changed file when the tool ist started next. I want to avoid that the file is stored outside my distributed directory and that the user needs to specify where it is (at least) the first time the tool ist started.
I am able to include the xlsx-file in my code such that the compiled version works correctly and obviously uses it. However, the file is not to be found in the directory distrib created by the compiler. It ssems to be included in the *.exe.
Is it possible to do what I want? If yes - how? If not - is it at least possible to include a template file for the xlsx which the user can get from the distributed directory without having to add it manually each time I create a new version of the tool?

채택된 답변

Walter Roberson
Walter Roberson 2016년 1월 11일
You can use which() in the executable to determine where the file ended up when you added it to the project
If the location of the file is to be understood to be per-user then you may wish to look at setpref() / getpref() to save information between runs. One of the bits of saved information could be a date that you could compare to the file creation date returned by dir()
  댓글 수: 3
Walter Roberson
Walter Roberson 2016년 1월 11일
Programs are mostly started from icons, and icons are not in any particular directory. But if you meant the location of the .exe then see http://www.mathworks.com/matlabcentral/answers/182482-how-to-determine-application-exe-name-at-run-time
Jette
Jette 2016년 1월 11일
I meant the location of the .exe
And this link was exactly what I was looking for. Thanks for your quick reply

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

추가 답변 (1개)

Titus Edelhofer
Titus Edelhofer 2016년 1월 11일
Hi,
I would suggest the following:
  • Add the .xlsx to the compiled app
  • When the application starts and wants to read the .xlsx make a distinction: if it exists in the folder where the compiled app is, use it. Otherwise read from the archive and save it where the compiled app is (using pwd), so that the user may adapt for the next run.
Titus
  댓글 수: 2
Jette
Jette 2016년 1월 11일
I tried this but I always get something like this if I try to find out the folder (e.g. mfilename, ctfroot, which)
C:\Users\[username]\AppData\Local\Temp\[username]\mcrCache7.14.1\[ProgDirs]\[myfile].xlsx
However, this is not the directory I am executing my programm from (see also my comment on the answer of Walter Roberson )
Titus Edelhofer
Titus Edelhofer 2016년 1월 11일
Hi Jette,
Walter cites a thread for finding out the location of the .exe ...
Titus

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

카테고리

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