-
Re: Friend or no Friend - Serialization Example
"Larry Rebich" <lrebich@earthlink.net> wrote:
>How do you Serialize? I have never used this! Do you have a sample?
Here's a sample.
Imports System.IO
Imports System.Runtime.Serialization.Formatters.Soap
Module Module1
Sub Main()
Dim op As New Options()
op.ListboxSetting = 5
op.DefaultFilePath = "C:\New Folder"
Dim stream As FileStream = File.Create("Options.xml")
Dim xml As SoapFormatter = New SoapFormatter()
xml.Serialize(stream, op)
stream.Close()
stream = File.OpenRead("Options.xml")
Dim xml_op As Options = CType(xml.Deserialize(stream), Options)
Console.WriteLine(xml_op.ListboxSetting & " " & xml_op.DefaultFilePath)
Console.Read()
End Sub
End Module
<Serializable()> Public Class Options
Private _ListBoxSetting As Integer
Private _DefaultFilePath As String
Public Property ListboxSetting() As Integer
Get
Return _ListBoxSetting
End Get
Set(ByVal Value As Integer)
_ListBoxSetting = Value
End Set
End Property
Public Property DefaultFilePath() As String
Get
Return _DefaultFilePath
End Get
Set(ByVal Value As String)
_DefaultFilePath = Value
End Set
End Property
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks