Reputation: 3024
i have my c# application in c:\program files\app\ folder i am using sqllite database
my code working perfectly while logging via windows administrative user, if i change window user account to limited, i couldn't open my database
public void OpenDB()
{
SQConnectionString = "Data Source=" + DBPath +";Pooling=true;FailIfMissing=false";
con = new SQLiteConnection();
con.ConnectionString = SQConnectionString;
con.Open();
}
Upvotes: 0
Views: 583
Reputation: 292425
The Program Files directory is definitely not the right place to put data... On Windows Vista and Seven, this directory can't be written to unless the application is running as administrator. You should put the database in ProgramData or the user's data directory. You can obtain these directories with the Environment.GetFolderPath
method :
string userAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
// On Vista and Seven, this is C:\Users\<username>\AppData\Roaming
// On XP, this is C:\Documents and Settings\<username>\Application Data
string commonAppData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
// On Vista and Seven, this is C:\ProgramData
// On XP, this is C:\Documents and Settings\All Users\Application Data
Upvotes: 2
Reputation: 3518
That's because non-admin users don't have write access to the program files
folder
Upvotes: 0
Reputation: 146229
Does the non-admin user have write
privileges on the directory where you installed SQLite? Because this might happen if you are using the journal file.
Upvotes: 0