Namespace SerializeTest Class Foo a As Long b As Long c As Long d As Long Public Sub Foo() a=100 b=200 c=300 d=400 End Sub End Class Sub TestMain() ' 一時ディレクトリを取得 Dim tempDir = GetExclusiveTempDirPath( "SerializeTest" ) ' fooインスタンスを生成 Dim foo = New Foo '---------------------------------------------------------------- ' シリアライズ '---------------------------------------------------------------- ' 保存先のファイルを開いて、 Dim fooXmlFilePath = tempDir + "\foo.xml" Dim fs = New System.IO.FileStream( fooXmlFilePath, System.IO.FileMode.Create ) ' シリアライズして、 Dim serializer = New System.Xml.Serialization.XmlSerializer( foo.GetType() ) serializer.Serialize( fs, foo ) ' 閉じる。 fs.Close() '---------------------------------------------------------------- ' デシリアライズ '---------------------------------------------------------------- ' 読み込んでみる。 Dim doc = New System.Xml.XmlDocument doc.Load( tempDir + "\foo.xml" ) System.Diagnostics.Debug.WriteLine( doc.OuterXml ) ' TODO: デシリアライズは未完成( ̄□ ̄;) End Sub End Namespace SerializeTest.TestMain()