Storing XML data for use with an addin
Asked Answered
R

1

2

I am in the process of creating an outlook addin. The addin works sort of like an aggregator. In this addin, the user will need to specify multiple sets of account information for the addin to have access to...see below:

<Accounts>
  <Account>
    <id>blah1</id>
    <password>blah1 again</password>
  <Account>
  <Account>
    <id>blah2</id>
    <password>blah2 again</password>
  <Account>
  <Account>
    <id>blah3</id>
    <password>blah3 again</password>
  <Account>
</Accounts>

So far I have thought that this should be something simple and light, like an xml data set or some such.

What are my best options for this? If it is an xml file, how do I get to it while I am debugging (i.e. what is the path to the file at both dev and run time). Should I be using the registry (yuck!), should I be looking in a different direction all together?

Thanks!

Robbert answered 4/4, 2012 at 20:54 Comment(0)
O
3

You should create a directory and file per user in the LocalApplicationData folder.

Account Settings Source: C:\Users\\AppData\Local\My Company\account-settings.xml

string userSettingsPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

// build company folder full path
string companyFolder = Path.Combine(userSettingsPath, "My Company");

if (!Directory.Exists(companyFolder)) 
   Directory.CreateDirectory(companyFolder);

// build full settings path
string fullSettingsPath = Path.Combine(companyFolder, "account-settings.xml");

Note: If you need to support roaming user profiles, you should consider using the ApplicationData special folder in place of LocalApplicationData.

Outwardly answered 5/4, 2012 at 20:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.