well i use this
''' <summary>
''' maakt van een byte array een object
''' </summary>
''' <param name="Argdata"> de ruwe binaire data </param>
''' <returns></returns>
Private Function DeSerialize(ByV al Argdata() As Byte) As Object
Dim m As New MemoryStream(Ar gdata)
Dim b As New BinaryFormatter ()
m.Seek(0, 0) 'start
Return b.Deserialize(m )
End Function
''' <summary>
''' Maakt van een Object (foo) een byte array .
''' </summary>
''' <param name="Argdata"> argdata als foo object</param>
''' <returns></returns>
Private Function Serialize(ByVal Argdata As Object) As Byte()
Dim b As New BinaryFormatter
Dim m As New MemoryStream
b.Serialize(m, Argdata)
m.Seek(0, 0) 'start
Return m.ToArray
End Function
to serialize and deserialize objects in my projects ( i store the byte array
in a sql server , but just as easy you could write it to a file )
example
<Serializable() _
Private Structure Selection
Dim ControlSoort As ControlType
Dim Vals As Object
Dim Tooltip As String
Dim Dsc As String
End Structure
Dim vals As Selection = CType(DeSeriali ze(CType(drH.It em("ControlWrd" ),
Byte())), Selection)
where drH.Item("Contr olWrd") is the binary data storded in my database , i
have chosen explicitly not to use XML as Binary serialization and
deserialization is
1. more compact 2. much faster 3. i do not want people easy to see what is
stored in the fields
HTH
Michel Posseth
"John" wrote:
Hi Michael
Is there a code link I can check?
Thanks
Regards
"Michel Posseth [MCP]" <MS**@posseth.c omwrote in message
news:um******** *****@TK2MSFTNG P05.phx.gbl...
well for serializing and deserializing you must at least have an
interface
if you can provide a generic interface in your situation ...... then it
is possible
regards
Michel
"John" <Jo**@nospam.in fovis.co.ukschr eef in bericht
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
Presumably deserialize requires knowing what object type to expect when
reading file? My problem is my appe will not know beforehand what objects
to expect. Would deserialize still work?
Thanks
Regards
"Michel Posseth [MCP]" <MS**@posseth.c omwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
i personally would just serialize and deserialize the hole control to
disk , much easier
regards
Michel
"John" <Jo**@nospam.in fovis.co.ukschr eef in bericht
news:%2******* *********@TK2MS FTNGP04.phx.gbl ...
Hi
I am trying to save settings of controls on my form to a file so I can
read them back later and recreate the controls on the form. I have
figured out how to go through all controls and get their properties
(see code below). What I am not sure is; how and what type of file
format I need to save the info to and how to read it back. Would
appreciate any help on that. A code snippet would be very much
appreciated .
Many thanks
Regards
For Each Ctrl In rootControl.Con trols
Props = TypeDescriptor. GetProperties(C trl)
' Write control name to a file here - how?
For Each Prop In Props
If Prop.IsBrowsabl e Then
PropName = Prop.Name
PropValue = Prop.GetValue(C trl)
' Write control properties to a file - how?
End If
Next
Next