copyright 1999 - 2014 by heinz prelle - hannover  - lenbachstraße 42 - | impressum
Beispiel: VB .Net - Array binär speichern
Option Explicit On
Option Strict On

Imports System.IO

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
            Handles MyBase.Load
        With Me
            .Text = "Testform <Array binaer speichern...>"
        End With
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
            Handles Button1.Click
        Me.InitAndSaveArray(Path.Combine(Application.StartupPath, "test.bin"))
    End Sub

    Private Sub InitAndSaveArray(ByVal Path As String)
        Dim m() As Members = _
            {New Members("Pinkel", "51", "Paolo"), _
             New Members("DeVaux", "39", "Bernhard"), _
             New Members("Chambers", "32", "Georgious")}

        Dim bf As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
        Dim Stream As FileStream = New FileStream(Path, FileMode.Create)
        bf.Serialize(Stream, m)
    End Sub

End Class

<Serializable()> _
Public Class Members

    Public MemberName As String
    Public MemberNumber As String
    Public MemberFirstName As String

    Public Sub New(ByVal MemberName As String, ByVal MemberNumber As String, ByVal MemberFirstName As String)
        MyClass.MemberName = MemberName
        MyClass.MemberNumber = MemberNumber
        MyClass.MemberFirstName = MemberFirstName
    End Sub

End Class
Sourcecode Visual Basic