Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

xmlWriter moving to end of file and write

Posted on 2005-05-08
3
Medium Priority
?
190 Views
Last Modified: 2011-08-18
Hello, I'm trying to have my error handler to write errors into xml file. I know how to create new xml file and write into it. but I'm facing problems when trying not to overwrite the exsisting file.
I'll appreciate any suggestions.
Thanks
Rod

       If File.Exists(errorLogFilePath) Then
            ' move to end of file and write error
            ' don't overwrite exsiting data
            ' ################# NEED HELP ON THIS PART #####################

        Else
            xmlWriter = New XmlTextWriter(errorLogFilePath, Nothing)
            With xmlWriter

                .Formatting = Formatting.Indented
                .Indentation = 4
                .IndentChar = " "
                .WriteStartDocument(False)
                .WriteStartElement("Error")
                .WriteAttributeString("errorID", "0")

                .WriteElementString("errorDate", errorDate)
                .WriteElementString("user", user)
                .WriteElementString("errorInfo", errorInfo)
                .WriteEndElement()
                .Close()
            End With

       End If
0
Comment
Question by:roddios
1 Comment
 
LVL 23

Accepted Solution

by:
b1xml2 earned 1000 total points
ID: 13957119
 With xmlWriter

      .Formatting = Formatting.Indented
      .Indentation = 4
      .IndentChar = " "
      .WriteStartDocument(False)
      .WriteStartElement("Error")
      .WriteAttributeString("errorID", "0")
      
      .WriteElementString("errorDate", errorDate)
      .WriteElementString("user", user)
      .WriteElementString("errorInfo", errorInfo)
      
      .WriteEndElement()
      'add this to close the document
      .WriteEndDocument()
      
      .Close()
End With
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Loops Section Overview
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question