Arokh
Well-known member
- Joined
- Apr 11, 2006
- Messages
- 124
[Posting frenzy he he]
Ive been using serialization for some time now and
it is perfect for easily storing data.
But some issue have come up:
Currently I have ~3000 entires (with each ~7.5kb) with file information packed into an array,
which is de- serialized upon opening/closing the program.
For deserialzing it almost takes 8 seconds which is already too long for my purposes and the entries will continue to grow.
Here is the Class I use for storing Fileinformation:
Most of the data is contained by DataContents in DataClass.
Im using the Binaryserialization since the XML one doesnt work (the dictionary object isnt supported, if I understood the error corretly).
So is there some way to speed it up,
or is serialzation not meant to store greater amounts of data?
If not, what alternative ways to store it are there?
My Serialization Methods:
Ive been using serialization for some time now and
it is perfect for easily storing data.
But some issue have come up:
Currently I have ~3000 entires (with each ~7.5kb) with file information packed into an array,
which is de- serialized upon opening/closing the program.
For deserialzing it almost takes 8 seconds which is already too long for my purposes and the entries will continue to grow.
Here is the Class I use for storing Fileinformation:
Code:
<Serializable()> Class FileClass
Public FilePath As New FilePathClass
Public ID(1) As Long
Public Data As New DataClass
<System.Serializable()> Class DataClass
Public DataContents As New Dictionary(Of String, Object)
Default Public Property Data(ByVal Path As String) As Object
Get
End Get
Set(ByVal Value As Object)
End Set
End Property
End Class
End Class
Im using the Binaryserialization since the XML one doesnt work (the dictionary object isnt supported, if I understood the error corretly).
So is there some way to speed it up,
or is serialzation not meant to store greater amounts of data?
If not, what alternative ways to store it are there?
My Serialization Methods:
Code:
Private Shared Function DeSerializeObj(ByVal FilePath As String) As Object
Dim SettingFileStream As IO.Stream = IO.File.OpenRead(FilePath)
Dim SettingLoader As New Runtime.Serialization.Formatters.Binary.BinaryFormatter
Try
Return SettingLoader.Deserialize(SettingFileStream)
Catch ex As Exception
MsgBox("Coudnt load " & FilePath & ". Specific settings reseted.")
Return Nothing
Finally
SettingFileStream.Close()
End Try
End Function
Private Shared Sub SerializeObj(ByVal Obj As Object, ByVal FilePath As String)
If Not My.Computer.FileSystem.DirectoryExists(My.Computer.FileSystem.GetParentPath(FilePath)) Then
My.Computer.FileSystem.CreateDirectory(My.Computer.FileSystem.GetParentPath(FilePath))
End If
Dim SettingFileStream As IO.Stream = IO.File.Create(FilePath)
Dim SettingSaver As New Runtime.Serialization.Formatters.Binary.BinaryFormatter
SettingSaver.Serialize(SettingFileStream, Obj)
SettingFileStream.Close()
End Sub