-1
我使用Visual Studio 2015年我有一个XML文件在我的解决方案Xml/file.xml
C#的Visual Studio 2015年加载XML
我写道:
XElement root = XElement.Load(@"Xml\file.xml");
我file.xml
属性是:
Build Action = Content
Copy to Output Directory = Copy Always
在调试模式下它可以工作,但是当我公开解决方案时,它搜索文件:
c:\windows\system32\inetsrv\Xml\file.xml
什么是解决方案?
感谢
你可以[确定实际路径(取决于这是什么类型的应用程序)](http://stackoverflow.com/questions/6041332/best-way-to-get-application-folder-path) – stuartd
当你发布,你正在改变你的exe的位置。您的根目录也更改为这个新位置。将文件移动到其查找的路径,或为该文件设置[绝对路径](http://stackoverflow.com/questions/4796254/relative-path-to-absolute-path-in-c)。 – Ethilium