Deployed exe with configuration file

6 ビュー (過去 30 日間)
Marc Elpel
Marc Elpel 2021 年 4 月 19 日
コメント済み: Marc Elpel 2021 年 4 月 19 日
My deployed Matlab apps include configuration data which is stored to custom *.cfg files. This works fine unless the installer is used in which case Windows locks the program directory and the config files cannot be updated.
There were a few old links on this topic but none seemed to address this specific issue. One referenced setpref/addpref, but that appeared to be configuring Matlab rather than the end user app. One suggested adding files to the deploytool "Shared" folder which does not exist. Some info on ctfroot() which seems to point to the app install folder but that is where files are being locked.
Restating the issue: I am compiling an app, it is being installed on a users computer, then the app needs to read/write the *.cfg file based on user interactions with the application. Some of the information is complex (such as custom filters); not just X = Y items.
Suggestions?

採用された回答

Rik
Rik 2021 年 4 月 19 日
It sounds like you need something very similar to my GetWritableFolder function.
You can use the second output to confirm the folder is persistent.
  5 件のコメント
Rik
Rik 2021 年 4 月 19 日
The default for APPDATA is the roaming folder (for reasons explained in a video by ThioJoe on YouTube recently).
My function has 3 possible outputs:
  1. A folder similar to where the AddOns are stored (%APPDATA% for Windows and ~\Documents\ for Mac/Unix)
  2. A folder in the tempdir
  3. A folder in the current directory
As long as the operating system paramaters do not change between calls, these paths should be stable, that is the whole point. This function should return the same output for a given OS/computer, and be able to return a folder.
You probably want this:
[f,status]=GetWritableFolder('ErrorOnNotFound',false);
if status~=1 && status ~=2
%handle the case of not finding a writable folder
end
Marc Elpel
Marc Elpel 2021 年 4 月 19 日
Thanks for all the help - this will work.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStandalone Applications についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by