Writable folder by all users on the same pc

Posted by Catalin DICU on Stack Overflow See other posts from Stack Overflow or by Catalin DICU
Published on 2010-04-14T09:27:52Z Indexed on 2010/04/14 9:33 UTC
Read the original article Hit count: 216

Filed under:
|
|

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 ?

© Stack Overflow or respective owner

Related posts about Windows

Related posts about .NET