存储XML数据以供外接程序使用 [英] Storing XML data for use with an addin

查看:84
本文介绍了存储XML数据以供外接程序使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个Outlook加载项.该插件的工作方式类似于聚合器.在此插件中,用户需要为该插件指定多组帐户信息,才能访问...,如下所示:

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>

到目前为止,我认为这应该是简单明了的东西,例如xml数据集或类似的数据.

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

为此,我最好的选择是什么?如果它是一个xml文件,则在调试时如何获取它(即在开发和运行时文件的路径是什么).我应该使用注册表吗(糟糕!),我是否应该同时朝着不同的方向看?

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?

谢谢!

推荐答案

您应该在

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

帐户设置来源:C:\ Users \\ AppData \ Local \ My Company \ account-settings.xml

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");

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

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

这篇关于存储XML数据以供外接程序使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆