How to make deployed program directory not read only

Hello
I have a compiled program (prog_name.m) that takes data from an external file (data.csv). The external file needs to be editable by the user, and the data from this external file is loaded into the program.
I included the external file in the "Files installed for your end user" section of the matlab compiler app.
When i install using the generated installer, the program installs to
C:\Program Files\prog_name\application
and in this folder there is my prog_name.exe and the external file (data.csv)
However, this folder always read only, and I can't edit data.csv without a fair amount of headache and changing file permissions. This isn't something I want the users to have to deal with. Is there a way I can make the installed folders not read only?
Im using windows 10 and R2020b
Thanks!

 採用された回答

Eric Delgado
Eric Delgado 2022 年 10 月 3 日
編集済み: Eric Delgado 2022 年 10 月 3 日

0 投票

In this case you should use AppData as default installation folder (see below). If this is not a solution, then you should put in the startup of your app a folder validation (Is the folder writable? If not, create a new one in ProgramData Windows folder, for example, copying your file "data.csv").
Your code will be something like that...
if ~isfolder(fullfile(getenv('PROGRAMDATA'), 'TheNameOfYourApp'))
mkdir(fullfile(getenv('PROGRAMDATA'), 'TheNameOfYourApp'))
movefile(fullfile(app.RootFolder, 'data.csv'), fullfile(getenv('PROGRAMDATA'), 'TheNameOfYourApp'));
end
% app.RootFolder is the path of your app

1 件のコメント

HpW
HpW 2022 年 10 月 4 日
Chainging the directory for installaton worked
thx

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

製品

リリース

R2020b

質問済み:

HpW
2022 年 10 月 3 日

コメント済み:

HpW
2022 年 10 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by