napsal jem ti ukázku Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim n As New Nastavení n.Nastavení.Add("ted", Now) n.Uložit("d:\0.bin") n.Načíst("d:\0.bin") End Sub End Class Public Class Nastavení Private _setting As New Dictionary(Of String, Object) Public Property Nastavení() As Dictionary(Of String, Object) Get Return _setting End Get Set(ByVal value As Dictionary(Of String, Object)) _setting = value End Set End Property Public Sub Uložit(ByVal soubor As String) Dim bf As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter Dim f As New IO.FileStream(soubor, IO.FileMode.OpenOrCreate, IO.FileAccess.Write) bf.Serialize(f, _setting) f.Flush() f.Close() End Sub Public Sub Načíst(ByVal soubor As String) Dim bf As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter Dim f As New IO.FileStream(soubor, IO.FileMode.Open, IO.FileAccess.Read) _setting = bf.Deserialize(f) f.Close() End Sub End Class
|