Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7001509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:48:43+00:00 2026-05-27T20:48:43+00:00

Next line sometimes is corrupting xml file and creating a zero length xml, when

  • 0

Next line sometimes is corrupting xml file and creating a zero length xml, when OutOfMemoryException has been thrown. How to prevent file corruption?

xmlDoc.Save(filename)

Save-Exception of type ‘System.OutOfMemoryException’ was thrown.
Save-at System.IO.FileStream.Write(Byte[] array, Int32 offset, Int32
count) at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean
flushEncoder) at System.IO.StreamWriter.Write(Char value) at
System.Xml.XmlTextWriter.Indent(Boolean beforeEndElement) at
System.Xml.XmlTextWriter.AutoComplete(Token token) at
System.Xml.XmlTextWriter.WriteStartElement(String prefix, String
localName, String ns) at
System.Xml.XmlDOMTextWriter.WriteStartElement(String prefix, String
localName, String ns) at System.Xml.XmlElement.WriteTo(XmlWriter w)
at System.Xml.XmlElement.WriteContentTo(XmlWriter w) at
System.Xml.XmlElement.WriteTo(XmlWriter w) at
System.Xml.XmlDocument.WriteContentTo(XmlWriter xw) at
System.Xml.XmlDocument.WriteTo(XmlWriter w) at
System.Xml.XmlDocument.Save(String filename) at
MainOptions.Save(String filename, ItemOptions options)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:48:44+00:00Added an answer on May 27, 2026 at 8:48 pm

    You’re overwritting the file as you save it to filename.
    To backup the old copy,

    • move it to another location (like filename.bak) before saving and
      delete it afterwards or
    • save the new file as another file (like filename.new) and rename it on success

    When an exception is thrown, you can easily restore the old/previous version of the xml file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For Each line As String In System.IO.File.ReadAllLines(file.txt) 'Do Something' Next and Using f As
file.each_line do |line| #skip the first one/not a user 3.times { next } if
We have next code. Sometimes we should wait 10-20-40 seconds on the last line.
My SaxParser implementation throws sometimes a org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: no element
Sometimes after a <div> class the next line comes on the same line and
Given that Decimal.MaxValue = 79228162514264337593543950335m Why does the next line give me 7922816251426433759354395034M in
How can I make my text wrap automatically to the next line when I
I want to be able to select the div next in line (its not
I have this line below that shows a link to go the next page
How do I skip over this next line if it turns out to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.