0

我需要一些帮助,拜托。

我想从 xml 文件加载数据,但我收到一条错误消息:“找不到文件 'C:\Users\someuser\Desktop\MyApp\MyApp\MyData.xml'。”

我的代码有一部分:

string dataPath =AppDomain.CurrentDomain.BaseDirectory + "MyData.xml";
XDocument xmlItems = XDocument.Load(dataPath);

在调试中,我看到 dataPath 有这个值:

"C:\\Users\\someuser\\Desktop\\MyApp\\MyApp\\MyData.xml"

我需要

"C:\Users\someuser\Desktop\MyApp\MyApp\MyData.xml"

当我使用 xml 文件的完整路径时,它工作正常。

4

0 回答 0