read/write a struct into a file

edwingt

New member
Joined
Aug 19, 2003
Messages
1
I have a struct in vb.net like:

structure test
dim element1 as string
dim element2 as integer
dim element3 as bool
end structure

dim varTest as test


I want to write and read the whole struct variable varTest
in a file.

I already try with fileput command like

fileput(freefile,binarymodeRead,varTest)
and it looks like it work

but when I try to read de struct with fileget
fileget(freefile,binarymodeWrite, varTest)
the app give me this error

Is there another way to read/write the whole struct into or from
a file.
 
I would recommend looking into XML Serialization for doing things like that. XML Serialization the object or objects you want to write to a file a lays them out in an XML file. If you search Google for XML Serialization you should find a lot of examples and tutorials. And then use Deserialization to read back the file.
:)
 
Back
Top