I made a simple WPF application in Visual Studio.
It accesses its own database file in its own directory with this connection string:
System.Environment.CurrentDirectory + @"\Data\" + databaseFileName;
I clicked Publish and basically accepted all the defaults (CD/DVD publishing, no online updates).
I copied the setup folder to another computer.
On the new computer I double-clicked setup.exe.
It installs fine, is in the start menu, but when it runs, it gets this error:
I've given the application all the permissions I can in project/properties/security:
What do I have to change so that this application deployed with ClickOnce can find its database in the relative directory below the .exe file, i.e. "Data/MainData.mdf"?
ADDENDUM The fix in the answer below works for Windows 7, but on Windows XP, I get this: