Legt ein serialisierbares Object auf der HD ab.
Function GetFileAsObject(ByVal FileName As String) As Object
Dim formatter As System.Runtime.Serialization.IFormatter = _
New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim stream As System.IO.Stream = _
New System.IO.FileStream(FileName, System.IO.FileMode.Open, _
System.IO.FileAccess.Read, System.IO.FileShare.Read)
GetFileAsObject = formatter.Deserialize(stream)
stream.Close()
End Function
Public Sub PutObjectAsFile(ByVal obj As Object, ByVal FileName As String)
Dim formatter As System.Runtime.Serialization.IFormatter = _
New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim stream As System.IO.Stream = _
New System.IO.FileStream(FileName, System.IO.FileMode.Create, _
System.IO.FileAccess.Write, System.IO.FileShare.None)
formatter.Serialize(stream, obj)
stream.Close()
End Sub
Kommentare zum Snippet