If I include a SQL LocalDB database in my C# (Visual Studio 2013) project (it's in a folder within the startup (.exe) project) it is 'automatically' deployed, using Click-Once, into the user's Local App folder:
C:\Users\-username--\AppData\Local\Apps\2.0\D81H6PTY.RC9\RO8MJQK4.2EH\words.exe_580cc2c54071d5a8_0001.0000_none_18b7548a68040a36
and then, in this folder, in the directories as specified in my VS project. These project folders for the database are matched by the Connection string in App.Config which contains:
attachdbfilename=|DataDirectory|AzureGulf\Words\Database\Wordz.mdf
I have tried a number of ways to get the run-time resolution of the |DataDirectory| path, including AppDomain.CurrentDomain.GetData("DataDirectory"), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) and so on...
If I publish a newer version of the program and install it, it automatically includes the 'older' database but places this is a 'newer' set of Apps\2.... folders - this is quite a neat feature but as the current database moves into a new folder with each published version, I really need a way of programmatically telling the user where the database is.
Any pointers appreciated.