Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top