This is using C# coded using Microsoft Visual Studio 2019 Professional

I have an XML file used as a configuration in my program that I am coding. The executable reads and writes to the XML file. So I would naturally like to have an automatic process where the XML file is moved from where it resides among of the source to where the compiled executable will be built. I imagine the moving of the xml file could be done during the pre-build or post-build process. And so, I tried adding some "xcopy" messages in the "Build Events" box that is found in the Properties setting of the project file. Another optioni, I assume, is to edit the project file by hand using a text editor. But I am not accustomed to the scripting language of this code. When I tried to type the pre-build commands I tried:

xcopy config.xml $(OutDir)config.xml

and the error during the Build is

The command "xcopy config.xml bin\x64\Debug\config.xml" exited with code 4.

Please help.

If you richt-click your file, then choose "Properties", you will see "Copy to output directory" which is set to "Do not copy".

Choose "Copy always".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.