Compile version of program doesn't recognise a file location

I created a function to write text to a file in the folder where the matlab file is running. It works fine. but when I compile it, its askign for the file to be in my users\apdata etc folder. How do I get around this as I want to share it and don't want the users to have to do this?
function pathtext = WriteFileToActingDir(hObject, eventdata, handles,text, file ) %Write String 'text' to a file 'file' in the current operating directory % Detailed explanation goes here
prog = mfilename('fullpath'); %Get current program path & name
[progpath,name,ext] = fileparts(prog); %Split out folderpath
pathtext = fullfile(progpath,file); %Build new filename
fid = fopen(pathtext, 'w');
fprintf(fid, '%s', text);
fclose(fid);
end

1 件のコメント

Adam
Adam 2014 年 10 月 30 日
I ended up setting up a MATLAB_HOME environment variable that is setup by our compiled programs where needed. This can then be used as a known working directory on the target machine rather than some hard-coded assumption or something that ends up being relative to some strange install folder.
It took a bit of time to get right (we have a config text file too which sits in that location and sets up user preferences) but it did at least solve the problem of where to write files on an arbitrary user's machine.

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

 採用された回答

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB Compiler についてさらに検索

質問済み:

2014 年 10 月 30 日

回答済み:

2014 年 10 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by