G
Guest
Hello,
I am using System.Xml.XmlTextWriter in my application in order to
store some application settings to an xml file.
The code goes like this
------------------------------------------------------
public void Write(string a_sConfigFilePath)
{
XmlTextWriter xmlWriter = null;
try
{
xmlWriter = new XmlTextWriter
(a_sConfigFilePath,System.Text.Encoding.UTF8);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.Indentation = 4;
xmlWriter.Namespaces = true;
xmlWriter.WriteStartDocument(true);
xmlWriter.WriteStartElement(m_sNamespacePrefix, ROOT_ELEMENT,
m_sNamespace);
xmlWriter.WriteStartElement(m_sNamespacePrefix, APPLICATION_ELEMENT,
m_sNamespace);
xmlWriter.WriteAttributeString("Name", m_sNamespace, m_sApplication);
xmlWriter.WriteAttributeString("Executable", m_sNamespace,
m_sExecutable);
//Write the root level setting. Subsettings will be written
recursively
_WriteSetting(m_oRootSetting, xmlWriter);
xmlWriter.WriteEndElement();
xmlWriter.WriteEndElement();
xmlWriter.WriteEndDocument();
xmlWriter.Flush();
}
finally
{
if (xmlWriter != null)
xmlWriter.Close();
}
---------------------------------------
In some cases I end up with corrupt content such as this:
---------------------------------------
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<ac:AppConfiguration
xmlns:ac="http://www.logicdis.gr/Software/ApplicationConfiguration">
<ac:Application ac:Name="Foo" ac:Executable=".\Foo.exe">
<ac:Setting ac:Name="SalesMenInboxForm.lsvMessageHeader"
ac
atatype="System.String" ac:Assembly="mscorlib" ac:EditMode="None"
ac:Encrypt="False" ac
isplayStyle="FromDatatype" ac
escr=""
ac
ocumentation="">
<ac:Setting ac:Name="Column0" ac
atatype="System.Int32" ac:As" />
</ac:Application>
</ac:AppConfiguration>
-------------------
Note the the closing element of the first node is missing and that the inner
"Setting" node is corrupt (the attribute ac:As" should be ac:Assembly="..."
/>).
File system data corruption has crossed my mind (the file is stored on a
flash memory card) but the funny thing is that the file is not terminated
abruptly!
Only an inner portion of the document is missing!
Has anyonce come accross this?
Thanks for reading this.
I am using System.Xml.XmlTextWriter in my application in order to
store some application settings to an xml file.
The code goes like this
------------------------------------------------------
public void Write(string a_sConfigFilePath)
{
XmlTextWriter xmlWriter = null;
try
{
xmlWriter = new XmlTextWriter
(a_sConfigFilePath,System.Text.Encoding.UTF8);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.Indentation = 4;
xmlWriter.Namespaces = true;
xmlWriter.WriteStartDocument(true);
xmlWriter.WriteStartElement(m_sNamespacePrefix, ROOT_ELEMENT,
m_sNamespace);
xmlWriter.WriteStartElement(m_sNamespacePrefix, APPLICATION_ELEMENT,
m_sNamespace);
xmlWriter.WriteAttributeString("Name", m_sNamespace, m_sApplication);
xmlWriter.WriteAttributeString("Executable", m_sNamespace,
m_sExecutable);
//Write the root level setting. Subsettings will be written
recursively
_WriteSetting(m_oRootSetting, xmlWriter);
xmlWriter.WriteEndElement();
xmlWriter.WriteEndElement();
xmlWriter.WriteEndDocument();
xmlWriter.Flush();
}
finally
{
if (xmlWriter != null)
xmlWriter.Close();
}
---------------------------------------
In some cases I end up with corrupt content such as this:
---------------------------------------
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<ac:AppConfiguration
xmlns:ac="http://www.logicdis.gr/Software/ApplicationConfiguration">
<ac:Application ac:Name="Foo" ac:Executable=".\Foo.exe">
<ac:Setting ac:Name="SalesMenInboxForm.lsvMessageHeader"
ac

ac:Encrypt="False" ac


ac

<ac:Setting ac:Name="Column0" ac

</ac:Application>
</ac:AppConfiguration>
-------------------
Note the the closing element of the first node is missing and that the inner
"Setting" node is corrupt (the attribute ac:As" should be ac:Assembly="..."
/>).
File system data corruption has crossed my mind (the file is stored on a
flash memory card) but the funny thing is that the file is not terminated
abruptly!
Only an inner portion of the document is missing!
Has anyonce come accross this?
Thanks for reading this.