作为开发人员,我应该如何在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屋!