将连接字符串另存为xml文件

时间:2019-07-09 01:57:21

标签: c# xml

嗨,我正在尝试将连接字符串另存为xml文件,但是当我单击btnFinish时找不到该文件。还应该如何从xml文件的另一种形式加载或调用xml文件中的连接字符串

private void btnFinish_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(cs))
        {

            if (goodCon == true)
            {

                string fname = Path.GetDirectoryName(Application.LocalUserAppDataPath) + "\\ConnectionStrings.xml";

                XmlTextWriter writer = new XmlTextWriter(fname, null);
                writer.Formatting = Formatting.Indented;
                WriteConnectionStrings(writer, cs, osb);
                writer.Close();

                this.Close();

            }
            else
            {

                this.Close();
            }
        } 
    }

1 个答案:

答案 0 :(得分:0)

尝试使用- debug: msg: "{{ master_list| symmetric_difference(hostvars[item_host].status_of_files.results| json_query('[].{item: item, hash: stat.checksum}')) }}" loop: "{{ groups['test'] | difference([ master ]) }}" loop_control: loop_var: item_host 代替UserAppDataPath。看看这篇文章:What is the difference between LocalUserAppDataPath and UserAppDataPath?