2012-04-04 40 views
2

我正在创建一个Outlook插件。插件的工作有点像聚合器。在这个插件,用户将需要指定多组的帐户信息的插件来访问......请看下图:存储XML数据以用于插件

<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> 

到目前为止,我认为这应该是简单,重量轻,像一个XML数据集或一些这样的。

这是我的最佳选择?如果它是一个xml文件,我在调试的时候如何得到它(即在dev和运行时文件的路径是什么)。我应该使用注册表(yuck!),我应该一起看一个不同的方向吗?

谢谢!

回答

3

您应该在LocalApplicationData文件夹中为每个用户创建一个目录和文件。

帐户设置来源: C:\用户\\应用程序数据\本地\我的公司\帐户的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"); 

注:如果您需要支持漫游用户配置文件,您应该考虑使用ApplicationData特殊文件夹代替LocalApplicationData