作为开发人员,我应该如何使用 Windows Vista(和 Windows 7)中的特殊文件夹? [英] As a developer, how should I use the special folders in Windows Vista (and Windows 7)?
问题描述
我应该在哪里保存与我的应用程序相关的数据?我应该在哪里保存配置文件?我应该在哪里保存临时文件?我应该在文档"中进行吗?应用程序数据"?等等……
Where should I save data related to my application? Where should I save configuration files? Where should I save temporary files? Should I do it in "Documents"? "AppData"? Etc...
将数据保存到磁盘的最佳做法是什么(我猜是特殊文件夹的最佳做法?!)?
What is the best practice for saving data to the disk (I guess, best practice for special folders?!)?
推荐答案
ApplicationData:您的应用程序需要作为每个用户"数据且不属于其他类别的所有内容.标准配置文件会放在这里.
ApplicationData: Everything that your application needs as "per user" data and does not fall under other categories. Standard configuration files would go here.
CommonApplicationData: 不是每个用户"数据的所有内容.
CommonApplicationData: Everything that is not "per user" data.
LocalApplicationData:每个用户的非漫游数据.例如,您希望确保它仅存储在这台机器上的所有内容(如机器激活码,通常还有缓存/临时数据).标准的临时文件会放在这里.
LocalApplicationData: Data that is per user and non-roaming. For example, everything where you want to ENSURE that it is only stored on this machine (like machine activation codes, often also cache/temporary data). Standard temporary files would go here.
我的文档: 用户实际会识别为可识别的单个文档"的用户数据.
MyDocuments: User data that the user actually would identify as "recognizable single documents".
如果您不关心文件名,您还可以使用 tempfile API 在 temp
目录中生成临时文件.您不应该手动执行此操作.例如,在 .NET 中,您可以使用 Path.GetTempFileName()代码> 用于此目的.
If you don't care about the filename, you can also use a tempfile API to generate a temporary file in the temp
directory. You should NOT do this manually. In, for example, .NET you can use Path.GetTempFileName()
for that purpose.
这篇关于作为开发人员,我应该如何使用 Windows Vista(和 Windows 7)中的特殊文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!