0

There's a project that uses sqlite db file. It all works fine until I make setup file using Visual Studio installer. I'm aware of UAC limitations so I've created custom folder [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". 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. 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. Could you advise me where should I dig in order to get this fixed? Thanks in advance.

P.S. I'm using Windows 7, SP1

Kay
  • 65
  • 1
  • 7
  • There really arent SQLite DB permission, most likely the DB is marked readonly, or is readonly on the filesystem, or the user accessing the DB in windows doesnt have write access to the path of the db. – Jake H Feb 27 '17 at 15:59

1 Answers1

1

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

However rather than setting up permissions for the folders, you set them up for the sqlite file itself. It's pretty straightforward, you just set File.SetAccessControls instead of Directory.

Christian Barron
  • 2,695
  • 1
  • 14
  • 22