Writable folder by all users on the same pc
- by Catalin DICU
I have a desktop .NET WPF application witch uses an embedded database (SQLite).
Where to put the database file ? It's the same database for all users.
I tried to use CommonAppData but it's not writable by non-admin users. So I tried to use a custom installer action to give write rights to all users to this folder but it fails on domain PCs. The code is:
DirectorySecurity security = Directory.GetAccessControl(appDataPath);
FileSystemAccessRule rule = new FileSystemAccessRule("Users", FileSystemRights.WriteData,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow);
security.AddAccessRule(rule);
Directory.SetAccessControl(appDataPath, security);
Would ".\Users" insead of "Users" work on a domain ?
Is this the best approach ? Is there any other folder I could use ?