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.

有帮助吗?

解决方案

If the data apply at the whole addin, regardless of the user logged in, I suggest to write your XML file in the folder defined by Environment.SpecialFolder.CommonApplicationData

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

instead, if you have different data based on the current user, write in the the folder defined by Environment.SpecialFolder.ApplicationData

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top