How I use XDocument.Load() to get a file in the application directory

前端 未结 2 562
没有蜡笔的小新
没有蜡笔的小新 2021-01-19 01:57

I have a XML file in a folder in the project. I would like to use XDocument.Load(string) but do I have to write the complete path to the application as part of

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-19 02:29

    Another way that bypass the ressource issue is to add the file to project (same as the ressource solution), then click on the file and in the property tab choose "copy always" in copy to output path. That way the file will get copied to the output directory when you build and it's as simple as doing

     XDocument xml = XDocument.Load("Registro.xml");
    

提交回复
热议问题