在哪里存储应用程序数据在Windows 7和Vista [英] Where to store Application Data in Windows 7 and Vista
问题描述
我的应用程序需要,最喜欢的,存储数据。该应用程序是previously用在XP只在那里将存储在数据程序文件
。现在,我们的客户迁移至Windows 7,我不得不这样升级其存储在一个新的文件夹中的数据。我选择了的ApplicationData code>文件夹作为我以为我会被允许访问,而无需UAC的。
现在在某些Windows 7的机器,这是好的,但在其他人访问该文件夹失败,$ P $因为权限psumably,但与管理员运行privelidges程序工作正常。
我使用了错误的文件夹或者是这些情况异常值?在这两种情况下,究竟是什么样的东西的最佳做法?
我使用下面的C# SpecialFolder
来获取AppData文件夹的位置。
System.Environment.SpecialFolder.ApplicationData
System.Environment.SpecialFolder.ApplicationData code>为每个用户和漫游。这听起来并不像你想要什么。你似乎想计算机范围设置等应使用
System.Environment.SpecialFolder.CommonApplicationData code>。
由于 CommonApplicationData code>在所有用户之间共享,默认的访问控制是有限的。默认情况下标准用户不能在此位置写。建议的做法是在安装时创建
CommonApplicationData code>的子文件夹,并为其分配适当宽松的访问控制设置。
My application needs to, like most, store data. The application was previously used on XP only where it would store the data in Program Files
. Now that our customers are moving to Windows 7 I had to upgrade it so that it stored the data in a new folder. I opted for the ApplicationData
folder as I thought I would be allowed access without needing UAC at all.
Now on some Windows 7 machines this is fine, but on others access to the folder fails, presumably because of permissions, but when ran with Administrator privelidges the program works fine.
Am I using the wrong folder or are these cases outliers? In either case what is the best practice for this kind of thing?
I am using the following C# SpecialFolder
to get the AppData folder location.
System.Environment.SpecialFolder.ApplicationData
System.Environment.SpecialFolder.ApplicationData
is per-user and roams. That doesn't sound like what you want. You appear to want machine wide settings and so should use System.Environment.SpecialFolder.CommonApplicationData
.
Because CommonApplicationData
is shared between all users, the default access control is limited. By default standard users cannot write in this location. The recommended practise is to create a sub-folder of CommonApplicationData
at installation time and assign it suitably permissive access control settings.
这篇关于在哪里存储应用程序数据在Windows 7和Vista的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!