Reputation: 756
I have a WPF application and I'm using SQL Server CE on it. It works fine when debugging with Visual Studio, but when I install the application in any computer, an error message is shown saying:
Access to the database file is no allowed
and the path of my database(usually the folder where the application was installed C:/ProgramFiles
).
Upvotes: 3
Views: 751
Reputation: 126
Please check if the file is readonly, if it is readonly please uncheck before you open the same.
Upvotes: 0
Reputation: 216293
The folders C:\program files
or C:\program files (x86)
cannot be used to store writable elements of an application like a database file. This is a security change made in Vista and in Win7 (UAC).
You should choose a different location (MyDocuments, ProgramData or else) where to store your database file during setup.
When you debug in Visual Studio, you are running your application inside the Solution Directory and subfolder bin\debug where you have read/write permissions.
Upvotes: 3