在解决方案中查找文件
我有一个 xml 文件,例如 examplexml.xml,并将其存储在名为 SampleFolder 的文件夹中。层次结构如下:
解决方案->项目->SampleFolder->samplexml.xml。假设我在项目中一个名为 TestClass.cs 的类中,如何读取字符串中 xml 文件的所有内容。
让我们说,
[TestClass]
public class TestClass
{
[TestMethod]
public void TestMethod()
{
//TODO: Read all the contents of the xml file in a string.
}
}
我该怎么做?
I have an xml file say samplexml.xml and I have stored it in a folder called SampleFolder. Here how the Hierarchy is:
Solution->Project->SampleFolder->samplexml.xml. Suppose I am in a class called TestClass.cs that is in the project, How can I read all the contents of the xml file in a string.
Let's say,
[TestClass]
public class TestClass
{
[TestMethod]
public void TestMethod()
{
//TODO: Read all the contents of the xml file in a string.
}
}
How do I do this??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试:
记住你应该设置编译器将 xml 文件复制到目标目录
Try:
Remember you should set compiler to copy xml file to destination dir