I've created and deployed an app which includes access to various files that get installed into the Program Files/MyApp folder via the Installer.

These include an MDB file and some WAV files.

To create the db connection string, I have used:-

pathstr = "Provider= Microsoft.Jet.OLEDB.4.0;Data Source="
pathstr += IO.Path.GetDirectoryName(Application.ExecutablePath)
pathstr += "\books.mdb"


I've also tried each of the following ways of trying to point to the mdb and wav files in the C:\ProgramFiles\MyApp folder:


Application.StartupPath
IO.Path.GetDirectoryName(Application.ExecutablePath)
IO.Path.Combine(Application.StartupPath, <MDB FileName>)
[Assembly].GetExecutingAssembly.Location


In every case, it works fine if I fire up the application from within the Program Files folder itself. But of course in the real world I want users to run the app from the StartMenu and so have put a shortcut in there for them to use in the usual way.

And that's where the problem is.

When the app is fired up from there, the application itself will run OK, BUT all the above variations of paths point to :-

C:\Documents and Settings\<User Name>\StartMenu\Programs\MyApp

and so of course the app doesn't find the mdb or wav files because they're not in that folder.

I'm obviously missing something really simple here, but I just can't seem to track down the right way of pointing the app to those files in all situations.

So, the question is:- what code should I use to ensure that the app will find the mdb and wav files, no matter which folder it is fired up from - ie. the Start Menu or from within the Program Files folder?


Any help on this one much appreciated.