i am adding tracing for audit purposes of a simple process i have built as an .exe and set in the scheduler to run every 10 minutes. i want to have the application output the results into an xml file.
if the file exists then open and append data to it, if it does not exist i want to create a new xml file that will be persisted and used on next run.
here is my code now, what do i need to add, how do i open the xml file (on c:/file.xml) and use it to append nodes to?
also i think my code is like a newbs, so some help in showing me the correct streamlined way would help me learn best practice with C#/ XML
string err = "";
XmlDocument doc = new XmlDocument();// Create the XML Declaration, and append it to XML document
XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);
doc.AppendChild(dec);// Create the root element
XmlElement root = doc.CreateElement("STATS");
// Create URL's
XmlElement urlNode = doc.CreateElement("keepalive");
WebProxy wp = new WebProxy("http://proxy.ml.com:8083/");
WebClient w = new WebClient();
w.Proxy = wp;
if (w.DownloadString("http://wwww.idealcoding.com") != "")
catch (Exception ex)
err = ex.Message;
this is my XML file:
<keepalive runTime="11/22/2010 9:40:43 AM" result="UP" />