I'm using LINQ to XML I have a bit of a problem with writing to a XML file. It seems that instead of inserting XML nods the framework is writing to the XML file as a streamer, line by line.
I'm using a XML file to record my program events aka logging. If the program is closed before all processes are finished the XML logging file ends up being unfinished.
I would expect, as the process runs, for the program to keep the tags and just keep on adding <event> nods with log entries ( and it works fine if I let it run ) but if the process is interrupted I end up with something like this:
<root>
<processInfo>
<\processInfo>
<events>
<event>
This is my logging event info. It was cut off in the mid
How can I avoid this problem and make sure that even if my program process is interrupted the XML Logging file closing tags are still there ?
Thank you.
<root><processInfo><\processInfo> <events> <event> //Logging event info <\event> <\events><root>
The blog doesn't help much. It just has basic info how to use XDocument.Save().
Wdosanjos, I thought about collecting process log entries in a collection and then recording them to the XML file only at the using when Dispose() gets called. But what if the process freezes or user desires to end task it.. there will be no log file created correct ?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
IDisposable Interface (System)
http://msdn.microsoft.com/en-us/library/system.idisposable.aspx