Search code examples
c#xmlxmldocument

Copy XML into OutputDirectory of Other Project


I run this code in one C# project. The file is in the root of the project. Ant it has set Copy to output directory to copy always.

   XDocument fileConfigXml = XDocument.Load("FileConfig");

That project is being invoked from other project.

I get:

System.IO.FileNotFoundException was unhandled
  HResult=-2147024894
  Message=Could not find file 'C:\Users\user\SolutionName\OtherPriect\bin\Debug\FileConfig.xml'.

Can I copy xml file to the caller project or read it form its domestic project?


Solution

  • The XML-File must be in the Project which is the executed program. Otherwise it will only copied to the Output-folder of the referenced Project. A reference to a project means, that you use the .dlls but not the other files.