relative paths in a deployed (msi, not clickonce) application  
Author Message
W.J. Llope





PostPosted: Visual C++ General, relative paths in a deployed (msi, not clickonce) application Top

hi folks - i've successfully deployed a simple unmanaged .NET-less C++ app, and during runtime this code tries to open and read a data file that was deployed along with the app. the application never finds the file, and i've tried a lot of different relative paths in the code... the file is there, correctly deployed and right where i expect it on the target machine, but the app just never finds it where it expects it.

on the dev machine, i have a project folder "A" and the dir structure

.../A/ all sources

.../A/runtime/ folder containing the data file

.../A/Release/ folder containing the application

if, in the code, i provide the filename to open as "./runtime/data.dat" the app finds the file if the app is run from inside visual studio ("Debug > Start Without Debugging"), but does not if i double-click on the app in windows explorer. so, somehow VS knows that the app is sitting in the Release folder and the base directory for any relative paths is the top or code folder.

if, in the code, i provide the filename to open as "../runtime/data.dat" the app does not find the file if the app is run from inside VS, but does find the file if i double-click on the app in windows explorer.

all this makes some sense to me.

but i then build the MSI file using a Setup and Deployment Project, and copy that to another machine, and install it. on the target computer, the file system is set up as

C:\Program Files\MyName\AppDir contains the application etc

C:\Program Files\MyName\AppDir\runtime\ contains the data file

no matter what relative path i try in the code, the deployed application never finds the data file. i've tried things like "runtime/data.dat", "./runtime/data.dat", plus similar versions but with backslashes, plus some i knew couldn't work like "../runtime/data.dat. i even tried using an absolute path in the code that correctly pointed to the location of the data file on the target machine.

no go.

would greatly appreciate any guidance.... cheers,

bill



Visual C++2  
 
 
W.J. Llope





PostPosted: Visual C++ General, relative paths in a deployed (msi, not clickonce) application Top

argh...

i made a simple console app that uses fstream to read a 10 line text file and of course that worked perfectly as deployed on the target computer.

turns out my problem had nothing to do with the file path syntax. i was doing all of that correctly. however, i needed to look closer at what dependency walker was telling me (i was, in fact, missing a couple of run-time libraries).. buried in the million lines of output during profiling, there were a few key comments which pointed me in the right direction.... it's funny actually, depends.exe error lines written in red i've always been able to ignore, but it was the couple lines in very light gray that were the key ones!

so everything's deploying and running great now - sorry for the noise!! cheers, bill