My issue is that I can’t have the XML’s file name be saved based on the text of a given field: here is the line:
XmlTextWriter writer = new XmlTextWriter(@"{0}\ops\op-" + OpName.Text.Replace(" ", "_") + ".xml",
System.Text.Encoding.UTF8);
The issue I get is that it can’t find the path: C:\[stuff]\{0}\op\op-.xml and if I remove the {0}(in the code) I get can't find C:\op\op-.xml
I am needing it to find C:\[stuff]\op\ so it can make the file in that folder.
How could I change this line?
What does
{0}represents in your path?XmlTextWriterconstructor takes file path, not a formatted string. It would be much more readable if you’d prepare your file path in steps, eg. by utilizing Path.Combine method: