3

I am writing a simple VS2012 AddIn and I am not sure where and how I should store data that I need to reuse the next time the AddIn is opened. I was thinking about simply storing the data in an XML file in the same folder as the binary but then I started thinking that there ought to be a smarter way to persist user data in an AddIn, maybe it is common to save it in a system or user folder?

Thus my question is: Is there any best practice on how/where to store data from a VS2012 AddIn?

Any help greatly appreciated.

4

1 回答 1

2

如果数据适用于整个插件,无论用户是否登录,我建议将您的 XML 文件写入定义的文件夹中Environment.SpecialFolder.CommonApplicationData

 string commonPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData));
 string myAddinDataPath = Path.Combine(commonPath, "MyAddinName");
 if(!Directory.Exists(myAddinDataPath)) Directory.CreateDirectory(myAddinDataPath);

相反,如果您有基于当前用户的不同数据,请写入由定义的文件夹Environment.SpecialFolder.ApplicationData

于 2013-05-27T14:17:10.940 回答