how to read binary data ¬ ( ) in xml using c# generated by windows . I am trying to access the List out the registry keys in the windows reg . There are binary data popping up in string value . I am able to serialize it using xml serialization ,to () but I am not able to de-serialize it back ? Can anyone explain me what is going wrong and why ? help me to fix this one . Many thanks :))) Error while reading is:
System.InvalidOperationException was unhandled
Message="There is an error in XML document (235, 28)." Read From file:
public diagnostics readregkey(diagnostics diagnostics, string filename)
{
diagnostics dia = null;
using (System.IO.StreamReader sr =
new System.IO.StreamReader(filename, Encoding.Unicode))
{
System.Xml.Serialization.XmlSerializer x =
new System.Xml.Serialization.XmlSerializer(typeof(diagnostics));
dia = x.Deserialize(sr) as diagnostics;
}
return dia;
}
Write to file:
public static void WriteRegKey(diagnostics diagnostics, string filename)
{
diagnostic.regKeys.Add(key(Registry.LocalMachine, sKeyGravitas));
diagnostic.regKeys.Add(key(Registry.CurrentUser, sKeyGravitas));
using (System.IO.StreamWriter sw =
new System.IO.StreamWriter(filename,false, Encoding.Unicode))
{
System.Xml.Serialization.XmlSerializer x =
new System.Xml.Serialization.XmlSerializer(typeof(diagnostics));
x.Serialize(sw, diagnostics);
}
}