Data Mining

Download Free Data Mining Source Code In C/C++, C#, Visual Basic, Visual Basic.NET, Java,
and other programming languages
Welcome to Data Mining Sign in | Join | Help
in Search

Data Mining Source Code Newsletter

Business Analyst Training
Live, Online, Video Courses
Instructor-Led + Hands-On
BusinessAnalystBootCamp.Com

SQL + Database Training
Live, Online, Video Classes
Instructor-Led + Hands-On
SQLBootCamp.Com

Software Developer Training
Live, Online, Video Courses
Instructor-Led + Hands-On
SoftwareDevelperBootCamp.Com

IT CAREER COACH
Hands-On Experience Coaching
IT Skills Training
IT-Career-Coach.NET

IT Professional Newsletter
"Free" IT Career Success Tips
How To Accelerate Your Career
IT Career Newsletter

Ask IT Career Questions
"ASK" A Burning IT Career
Question Or Get Answers
Ask A Burning IT Question Now!

Announcing The Data Mining Source Code Newsletter!

Subscribe By Email | Subscribe By RSS Feed

Serialize / Deserialize an Object with a Binary Formatter : VB.NET

Last post 09-12-2003, 13:25 by DotNetSmart. 0 replies.
Sort Posts: Previous Next
  •  09-12-2003, 13:25 684

    Serialize / Deserialize an Object with a Binary Formatter : VB.NET

    Example show how the serialize the individual objects using a Binary Formatter.

    I have commented the code very well. please let me know in case of any doubts.

    Thanks




    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    'Creating rectangle type object
    Dim R1 As New Rectangle
    'initializing the X object
    R1.X = 1
    'initializing the Y object
    R1.Y = 1
    'initializing the width object
    R1.Width = 10
    'initializing the height object
    R1.Width = 20
    'Creating rectangle type object
    Dim R2 As New Rectangle
    'initializing the X object
    R2.X = 10
    'initializing the Y object
    R2.Y = 10
    'initializing the width object
    R2.Width = 100
    'initializing the X object
    R2.Height = 200
    'creating the filestream
    Dim savefile As FileStream
    'create the file and return reference
    savefile = File.Create(Directory.GetCurrentDirectory & "\Shapes.bin")
    'creating Binary formatter
    Dim formatter As System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
    'intializing binary formatter
    formatter = New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
    'serializing the rectangle objects to the file
    formatter.Serialize(savefile, R1)
    formatter.Serialize(savefile, R2)
    'closing the file
    savefile.Close()
    MsgBox("Individual objects serialized successfully")
    End Sub

Announcing The Data Mining Source Code Newsletter!

Subscribe By Email | Subscribe By RSS Feed