我的c#应用程序位于c:\program files\app\文件夹中,我使用的是sqllite数据库
我的代码在通过windows管理用户登录时工作正常,如果我将windows用户帐户更改为limited,我无法打开数据库
public void OpenDB()
{
SQConnectionString = "Data Source=" + DBPath +";Pooling=true;FailIfMissing=false";
con = new SQLiteConnection();
con.ConnectionString = SQConnectionString;
con.Open();
}发布于 2009-09-22 12:33:23
Program Files目录绝对不是存放数据的正确位置...在Windows Vista和Seven上,除非应用程序以管理员身份运行,否则无法写入此目录。您应该将数据库放在ProgramData或用户的数据目录中。您可以使用Environment.GetFolderPath方法获取以下目录:
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发布于 2009-09-22 12:22:46
非管理员用户在安装SQLite的目录上是否具有write权限?因为如果您使用的是日记文件,则可能会发生这种情况。
发布于 2009-09-22 12:27:01
这是因为非管理员用户对program files文件夹没有写入权限
https://stackoverflow.com/questions/1459646
复制相似问题