Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
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.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900