Hello,
Could please somebody shed some light on how to write an array of Structure variables to file
The structure looks as follows:
Public Structure tUnit
Dim Name As String
Dim HP As Integer
Dim Armor As Integer
Dim Sphere As Sphere
Dim Moves As Byte
Dim TravelsTo() As Boolean
Dim Weapon() As tWeapon
Dim Current As tState
End Structure
Since TravelsTo() and Weapon() are custom variables themselves, it would be pretty tedious to manually save each variable (sw.Write(Name) etc.) with appropriate For...Next cycles for TravelsTo and Weapon, then do the reading part similarly.
In "standard" .NET I could very simply do this with an OpenFile command, opening the file for random access, then dumping the whole array into it in tUnit format. .NET Compact framework doesn't seem to support this though.
I'm using VS.net 2005, Visual Basic, .NET Compact Framework 2.0 for Pocket PC 2003.
Any help would be greatly appreciated :)

Saving Structure variables to a file
dutgoyi
You can either use XML serializer or do it the way you already mentioned.
Robert Lair
(Albeit it takes 830 bytes to store about 100 bytes of information :( but nothing is perfect, now is it! :)