Matlab Compiler: Is "userpath" always there and accessible?

조회 수: 34 (최근 30일)
William Thielicke
William Thielicke 2024년 11월 27일 14:37
댓글: Steven Lord 2024년 11월 30일 21:06
Dear all,
my compiled app needs to store some temporary files in the background. Is it safe to assume that the directory given by userpath will exist on all computers? And that we will always have write access to this folder?
Thanks!!
William
  댓글 수: 3
William Thielicke
William Thielicke 2024년 11월 27일 15:15
Thanks, I think this is safe enough for me. If someone really wants to break my tool by changing permissions or deleting folders, then he still can, and that is ok. I can still display an appropriate messagebox in this case.
Good point with the userpath reset, I'll add an
if isdeployed;userpath("reset");end
William Thielicke
William Thielicke 2024년 11월 27일 15:21
...well, userpath reset doesn't work with compiler unfortunately.

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

답변 (1개)

Steven Lord
Steven Lord 2024년 11월 27일 15:48
I would probably try using the tempdir and/or tempname functions.
  댓글 수: 2
William Thielicke
William Thielicke 2024년 11월 30일 17:54
But tempdir doesn't always return a path, right? I have the feeling that userpath might be better, because this directory is apparently always created by Matlab Compiler.
Steven Lord
Steven Lord 2024년 11월 30일 21:06
It ought to return a folder name, unless perhaps a user has done something unusual with certain environmental variables. The documentation says that the folder is not guaranteed to exist, but you can check that with exist and use mkdir to create the directory if it does not exist yet.

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

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by