0

I developed an application in WPF for local usage on a computer. This application contains a database file (SQLite) where the user can store and read data in it. This means the database file needs read and write permissions. I deploy the application with the Setup Wizard of Visual Studio 2019.

I can install the application on different computers and the application works. After the installation of the application the database file will be stored in the User's local app data folder like ...Users/Username/AppData/Roaming/... The problem is, this database can only be accessed by the user who installed the application. But I want that all users on the local system have access on this database file, so that the application will work on every user account on this computer.

So I need a folder location where every user and new users in future have access to store my database file. Additionally I've tried to store the database in the application folder (it's like C:\programms..., the standard thing), commonAppFolder (which is like C:\ProgramData) but nothing works because of the missing permissions in this folders. Is there any folder what I can configure my Setup wizard with? What is with the public folder in c:\users\? I have no options to choose that path in the setup wizard (no special folder or something)? Is there any recommended method of solving my problem with a database file that must have read/write permissions for every user, so that the application works for every user on the computer?

Hope you understand it, English is not my natural language.

coderone
  • 1
  • 2
  • Did you try to set your db file to the installation directory? – Sajitha Wattage Oct 30 '19 at 15:27
  • All users has access to C:\ProgramData as standard – Nawed Nabi Zada Oct 30 '19 at 15:30
  • But totally depending on your logic you should do something, if every user needs access to the same file then put it in the C:\ProgramData otherwise keep it in the installation directory and copy to %appdata% for each user. – Nawed Nabi Zada Oct 30 '19 at 15:32
  • In Installation Directory (C:\Programs\AppFolder\Database\Database.db) dont work! When I tried it in ProgramData\AppFolder\Database\Database.db, it doesnt work too. And copying the file for each user is not the way because then I have different databases for every user or did I get you wrong? – coderone Oct 30 '19 at 15:37
  • That is correct as standard users does not have write permisison to that folder – Nawed Nabi Zada Oct 30 '19 at 15:39
  • so again that depends on your logic, if you save all users settings and views in the database it makes sense to keep one file per user... We are talking about session users, different users logging in to the same machine. – Nawed Nabi Zada Oct 30 '19 at 15:41
  • No user settings in this db. For example I have stored names of employees in a table. When the user logs out from windows and another user logs in and starts the application he should have the same values as the other user. Tried ProgramData again. it doesnt work, no write permissions. – coderone Oct 30 '19 at 15:48
  • Well yeah... I see that now... Only write access for folders are permitted. You could permit write access to the database file it self while installing. You need to give write access for the MACHINE\Users security group. in that case it doesn't matter if you place it in the Program Files folder or ProgramData folder – Nawed Nabi Zada Oct 30 '19 at 15:58
  • Is this even possible with the Setup Wizard? Or can you give me a example or something how this works? – coderone Oct 30 '19 at 16:30
  • Nope! not as I know, you have to provide that as well, either in your program or as a separate app/script. here you have some examples of how to do that from code: https://stackoverflow.com/questions/8944765/c-sharp-set-directory-permissions-for-all-users-in-windows-7 – Nawed Nabi Zada Oct 31 '19 at 08:08

0 Answers0