3

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.
First question - is this correct?

So far, I've created a custom folder, set the DefaultLocation property to [LocalAppDataFolder][ProductName], and put the .sdf file in that folder.
This works in Windows 7, but it doesn't seem to work in Windows XP - I can't find any sign of it being deployed anywhere.

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.

2
  • What kind of app is it?? ASP.NET ? Winforms? Console? Service? Commented Nov 29, 2010 at 15:55
  • Winforms, sorry for not specifying it. Commented Nov 30, 2010 at 12:19

1 Answer 1

3

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);
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot. It really helped. So, in your opinion, AppData folder is the one in which to save the database file? Again, thanks for the idea.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.