简体   繁体   English

SQLite数据库在设置后变为只读

[英]SQLite database becomes read only after setup

There's a project that uses sqlite db file. 有一个使用sqlite db文件的项目。 It all works fine until I make setup file using Visual Studio installer. 一切正常,直到我使用Visual Studio安装程序制作安装文件。 I'm aware of UAC limitations so I've created custom folder [CommonAppDataFolder][Manufacturer][ProductName]. 我知道UAC的局限性,因此创建了自定义文件夹[CommonAppDataFolder] [Manufacturer] [ProductName]。 (C:\\ProgramData\\MyCompany\\MyProduct) Setup file creates the folder and puts the DB file there, however, the program crashes with exception "attempt to write a read-only database". (C:\\ ProgramData \\ MyCompany \\ MyProduct)安装文件创建该文件夹并将DB文件放在该文件夹中,但是该程序崩溃,并出现异常“试图写入只读数据库”。 The most interesting stuff begins when I take the same DB file that I've just added through Visual Studio Installer and put it to C:\\ProgramData\\MyCompany\\MyProduct. 当我将刚通过Visual Studio安装程序添加的同一数据库文件放入C:\\ ProgramData \\ MyCompany \\ MyProduct时,最有趣的事情开始了。 It should be essentially the same file, but when I add it manually - everything works just fine. 它应该基本上是相同的文件,但是当我手动添加它时-一切正常。 So I believe the problem is with Visual Studio Installer, it somehow messes up database permissions. 因此,我相信问题出在Visual Studio Installer上,它以某种方式弄乱了数据库权限。 Could you advise me where should I dig in order to get this fixed? 您能建议我在哪里进行挖掘以解决此问题? Thanks in advance. 提前致谢。

PS I'm using Windows 7, SP1 PS我正在使用Windows 7,SP1

I had this issue too! 我也有这个问题!

The problem isn't that the file is set as read-only but that the permissions aren't set to access the file. 问题不是文件被设置为只读,而是权限没有被设置为访问文件。

What I found I needed to do was follow the steps on the following thread to setup a custom action: How to give Read/Write permissions to a Folder during installation using .NET 我发现我需要做的是按照以下线程上的步骤设置自定义操作: 如何在使用.NET的安装过程中为文件夹赋予读/写权限

However rather than setting up permissions for the folders, you set them up for the sqlite file itself. 但是,不是为文件夹设置权限,而是为sqlite文件本身设置它们。 It's pretty straightforward, you just set File.SetAccessControls instead of Directory. 这非常简单,您只需设置File.SetAccessControls而不是Directory。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM