How to deploy SQL Compact Edition database file (.sdf) in AppData folder? Connection string

I plan to deploy my DB file in a folder Users\CurrentUserName\AppDatabecause the default account management settings restrict write access to the Program Files directory where my program is installed.
First question is right?

So far I have created a custom folder, set the DefaultLocation property to, [LocalAppDataFolder][ProductName]and placed the .sdf file in this folder.
This works on Windows 7, but it doesn't seem to work on Windows XP - I can’t find any sign that it will be deployed anywhere.

So where and how should I deploy the DB file?

I also don't know how to set the connection string to a location [LocalAppDataFolder]- any suggestions?

Edit: The application is a WinForms application that will be downloaded from the website and installed using the installer created using the Setup Project.

+3
source share
1 answer

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);
+3
source

Source: https://habr.com/ru/post/1777464/


All Articles