MATLAB: Do I get the Error using load. Unable to read file ‘‘. No such file or directory when running compiled application

MATLAB Compilermcr_cache_root

I have a compiled application that has throws an error:
" Error using load
Unable to read file '<file:///C:/Users/tawong/AppData/Local/Temp/tawong/mcrCache9.1/HEARTs0/data_analysis/E2E0070.txt'. C:\Users\xyz\AppData\Local\Temp\tawong\mcrCache9.1\HEARTs0\data_analysis\E2E0070.txt'.> No such file or directory. "
I use deploytool –> application compiler to compile the application and add a folder "data_analysis" to the "Files required for your application to run". The program runs fine and accesses the files in the data_analysis folder most of the time but every once in awhile I receive the above error. I then have to add the .txt file to that temporary folder manually. Is there something I can do so that I don't have to add the text files to that temporary location? I would like the information contained in the file to remain protected from access and tampering and that's why I include it in the compiling.

Best Answer

The default location for MCR cache directory is under a temp folder.
This might happen if some Windows program like Disk Cleanup is deleting files from Temp folder.
To fix this, change the location of MCR Cache Root by adding system environment variable-
MCR_CACHE_ROOT to some other location in directory.