Reputation: 2176
I have a c# project which I added a xml-file (Add -> New -> xml).
The property of the file for Copy to Output Directory
is set to Copy if newer
and in the project properties for Publish
-> Application Files
-> Publish Status
is set to Include
.
When I debug my project I read and write that xml-file and it is correct updating in the bin/Debug
folder but not in the main folder of the solution. So the xml-file in the solution is not updated, only the xml-file in the Debug
folder.
I know from other projects that I get a hint when I stop debugging after a xml-file was modified that the xml-file was updated and if I want to reload it. That hint I don't get so something must be wrong with the link to that file.
Upvotes: 0
Views: 1038
Reputation: 495
If you want to rewrite the XML file that is part of your project, you have to write to that XML file - not to the copy in your bin\debug folder. This is not generally what most people want. If the file is part of your project, most people would consider that a source file that you would want to keep in its original condition, not a file that you want to edit while debugging.
If that is what you want to accomplish, make sure you read and write to ..\..\MyFile.xml relative to your executable. That's assuming the XML file is in the root folder of your project, and that your project isn't configured to use any non-standard folder structure.
Upvotes: 2