XMLファイルにレジストリ情報を書き出しています。 ¬シンボルがregkeyの文字列の値として生成されています。 私はXMLに書き込むときに私はを取得しています。読み返してみるとエラーになります。これを克服する方法はありますか?どのように進めることができますか?Xmlでの読み書き方法
エラー読み取り中です:ファイルから
> System.InvalidOperationException was unhandled
> Message="There is an error in XML document (235, 28)."
読む:
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;
}
書き込みファイルに:
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);
}
}
を[?あなたはどちらエラーが出るん](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html)それが書かれている方法 –
?どのエンコーディングが使用されていますか?結果はどのように表示されますか?私はそのケースを処理するためにUTF-8またはUTF-16ファイル/ストリームを期待しています。 –
上記のコードを追加しました – Nisha