JumpyNET
Well-known member
- Joined
- Apr 4, 2005
- Messages
- 151
How can I save an array of custom structure type to a single file on harddisk?
I gues I would need to get the starting address and length of "ThisNeedsToBeStored"-array and save it byte by byte, but I dont know how to do it in VB.
My objective is to save and read back the array to a file as easily and fast as possible.
Below is an example of a structure I am talking about.
[VB]
Public Structure OwnStructB
Dim Aaaa As String
Dim Bbbb As Date
Dim Cccc() As String
End Structure
Public Structure OwnStructA
Dim Aaaa As String
Dim Bbbb As Date
Dim Cccc() As String
Dim Dddd() As OwnStructB
End Structure
Public ThisNeedsToBeStored() As OwnStructA
[/VB]
[VB]
Public Sub SaveObjectToFile(ByVal TheObject As OwnStructA, ByVal SaveFilePath As String)
?????
End Sub
Public Sub GetObjectFromFile(ByRef TheObject As OwnStructA, ByVal SaveFilePath As String)
?????
End Sub
[/VB]
PS: I did find one solution that can save and restore a structure, but I could not modify it to work with an array containing arrays. It uses serialization. Here is the link:
http://www.thescripts.com/forum/thread368181.html
I gues I would need to get the starting address and length of "ThisNeedsToBeStored"-array and save it byte by byte, but I dont know how to do it in VB.
My objective is to save and read back the array to a file as easily and fast as possible.
Below is an example of a structure I am talking about.
[VB]
Public Structure OwnStructB
Dim Aaaa As String
Dim Bbbb As Date
Dim Cccc() As String
End Structure
Public Structure OwnStructA
Dim Aaaa As String
Dim Bbbb As Date
Dim Cccc() As String
Dim Dddd() As OwnStructB
End Structure
Public ThisNeedsToBeStored() As OwnStructA
[/VB]
[VB]
Public Sub SaveObjectToFile(ByVal TheObject As OwnStructA, ByVal SaveFilePath As String)
?????
End Sub
Public Sub GetObjectFromFile(ByRef TheObject As OwnStructA, ByVal SaveFilePath As String)
?????
End Sub
[/VB]
PS: I did find one solution that can save and restore a structure, but I could not modify it to work with an array containing arrays. It uses serialization. Here is the link:
http://www.thescripts.com/forum/thread368181.html