Add new item in xml file from object



I have the code below that generates a xml from the object. Now what I need is to open the generated xml file and add a new record below the record already inserted.



string Arq = Path.Combine(Caminho, NomeArquivo);

StreamWriter Wr = null;

XmlSerializer x = null;
try
{
Wr = new StreamWriter(Arq);

x = new XmlSerializer(Objeto.GetType());

x.Serialize(Wr, Objeto);

Wr.Close();
}
catch (Exception ex)
{
Utilexcessao.TrateExcessao(ex);
}
finally
{
if (!(Wr == null))
Wr.Dispose();

if (!(x == null))
x = null;
}

No comments:

Post a Comment