I'm planning to deploy my DB file in the Users\CurrentUserName\AppData
folder, because default User Account Control settings restrict write access to the Program Files directory where my program is installed.
So far, I've created a custom folder开发者_高级运维, set the DefaultLocation property to [LocalAppDataFolder][ProductName]
, and put the .sdf file in that folder.
So where and how should I deploy the DB file?
I'm also unsure how to set the connection string to the [LocalAppDataFolder]
location - any suggestions?
Edit: The application is a WinForms application which will be downloaded from a website and installed using the installer created with Setup Project.
This works for me:
string fileName = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SqlCe35AddinStore.sdf");
string connString = string.Format("Data Source={0};", fileName);
精彩评论