如何在WPF中获取当前应用程序路径 [英] how to get current application path in wpf

查看:418
本文介绍了如何在WPF中获取当前应用程序路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public XML()
{
    this.InitializeComponent();

    XmlDocument document_name = new XmlDocument();       
    XmlElement student = document_name.CreateElement("Student");
    XmlElement name = document_name.CreateElement("Chandru");
    student.AppendChild(name);
    document_name.AppendChild(student);
    XmlAttribute id = document_name.CreateAttribute("ID");
    name.SetAttributeNode(id);
    id.Value = "sst5038";
    XmlElement fname = document_name.CreateElement("FName");
    fname.InnerText = "Anjappn";
    name.AppendChild(fname);
    XmlElement mname = document_name.CreateElement("MName");
    mname.InnerText = "Thaiyamuthu";
    name.AppendChild(mname);
    document_name.AppendChild(student);
    document_name.Save(@"D:\student.xml");
}

使用上述代码。我在wpf和i中创建了一个xml文件作为代码将此文件保存到本地磁盘D:Dstudent.xml

with above code.I create one xml file as code behind in wpf and i save this file in my local disk D:\student.xml

 document_name.Save(@"D:\student.xml");

但是我想将此xml文件(student.xml)保存在我正在工作的项目文件中现在。

But i want to save this xml file (student.xml) in my project file which i am working now.

我应该怎么做。

请帮助我...

推荐答案

这是您要寻找的房地产吗?

Is this the property you're looking for?

System.AppDomain.CurrentDomain.BaseDirectory

这篇关于如何在WPF中获取当前应用程序路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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