views:

35

answers:

2

I have an Sql Compact Database v3.5 that I'm bundling with my application. When the application is installed, the database is copied into the application's Program Files directory.

Because of Vista and Win7's security settings, the installed application can't access the database file. It is merely a problem of having the database file reside in the Program Files.

The solution I have thought of is to copy the file into Program Data, but does anyone have another solution? I am sure others have come across a similar problem.

Thanks in advance for your input.

A: 

store the application data in the user's application data directory. Or in 'default user'. The user has permission to this directory and that is the intended purpose.

http://blog.kowalczyk.info/article/Getting-user-specific-application-data-directory.html

Sky Sanders
Thanks for your help. Is it possible to allow the user to read from the database file but not write to it? Would this be allowed from the Program Files directory?
Quenton Jones
@quenton - You should be able to do that, but really it is not the appropriate location for data, especially if it is going to be run by the user as a user. Just look into your own AppData directory to see just how all of the apps you use store data there as opposed to Program Files.
Sky Sanders
A: 

Use the Environment.SpecialFolder property. Place the DB file either in the app data all users or app data of the specific user.

Probably will need some setting at install like most applications these days.

Marthinus