I see. You are correct about using XML. It would require loading the complete file. If that is what he wants to avoid, XML will not work for him.
-----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Ian Griffiths Sent: Friday, November 18, 2005 11:03 AM To: [email protected] Subject: Re: [ADVANCED-DOTNET] Writing data to the beginning of a file But didn't he start off by saying he wanted something better than writing out the entire file again every time he did an insertion? Moving to XML doesn't solve that file writing problem. You can insert stuff into an XML DOM, but the DOM is a data structure in memory. If you want the file on disk to contain the new entry, then you have to re-serialize the DOM. So you're getting the DOM to read the whole file in for you and write the whole thing back out again. Just because the DOM's doing this work for you doesn't change the fact that the work is still happening. If all you care about is how much development work is required, then your solution is fine. But if the problem you're trying to solve is the amount of disk activity required, then XML is likely to make things worse as it's probably going to be more verbose. So I guess now would be a good time for us to clarify the requirements. :) Could the original poster please tell us: is it the IO costs you're worried about, or the coding effort? -- Ian Griffiths -----Original Message----- From: Jon Rothlander Based on his questions, he is not using a windows event log and he seems to just be using his own log file design. Nothing in his post says that he does or does not have control over the format of the log file. If so, he may be able to use XML. If that is the case, which we cannot really tell unless he lets us know, he could use an XML file to hold the entries. Using XML allows for much easier access than a text based log file. In XML you can specify the location that you want to add a new node or element to. For example... <LogFile> <Entry Timestamp="2005-12-25-06:01:59:0000" Type="" Text="This is a sample entry" /> </LogFile> With XML you can insert an element anywhere you want. I can insert them before of after the last entry, before the first entry, or I can select one and insert the record before or after it. My point was that if he designed his own log file format, he can do whatever he wishes and could use XML for this. Of course, he may not be able to use XML if he is not controlling the log file format, which is why I asked the question. I personally use XML for this sort of log file all of the time. It's easy to build viewers via in windows or web that can have a lot of functionality. -----Original Message----- From: Steve Johnson On 11/18/05, Jon Rothlander <[EMAIL PROTECTED]> wrote: > > Can you use XML? If so, you can easily handle this using an XML log file. > How? =================================== This list is hosted by DevelopMentor. http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
