Where does a deployed application look for data files?

조회 수: 9 (최근 30일)
Gary
Gary 2015년 1월 16일
편집: Gary 2015년 1월 17일
I have compiled a MATLAB application into a .NET assembly. I can launch the assembly ok from C# (using Visual Studio 2013), but it fails when it looks for a file (using xmlstringinput) that is normally found in the MATLAB path (when not deployed).
I have tried placing copies of this file in a number of different places, with no success. I suspect that it will work to specify that the file be included in the deployment package, but I would rather that it load this file at runtime rather than be packaged with the deployment.
Where does a deployed application look for data files?

채택된 답변

Image Analyst
Image Analyst 2015년 1월 17일
You're best off not referring to files without the full path prepended. The folder where you put the executable is not the "real" folder where the "real" executable is located. What the first one does is to unpack the real executable and all the other stuff you included with it into some secret hidden folder. What I do is to ship data files and install them to some known location - a known folder - and then have my code point to it there. There are ways to get the actual folder it's running from if you need it.
  댓글 수: 1
Gary
Gary 2015년 1월 17일
편집: Gary 2015년 1월 17일
I have come to the same conclusion - that I need a fully qualified path. But I think the best approach (and perhaps you intended this) is to create a system environment variable (like MCRDeployedFilesPath) with the target folder name, and use it (e.g., pathname = getenv('MCRDeployedFilesPath')) for file loading.

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

추가 답변 (1개)

Gary
Gary 2015년 1월 17일
Sorry for my error - it does work to put the desired file(s) in the directory with the executable and the built DLL (.NET assembly).
However, it does not seem to work if instead I specify that the datafile be packaged with the assembly (using the -a option in the Compiler).

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by