Re: How to Read/Write objects to and from a file?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Geoff Schwab [MSFT] (a-geosch_at_online.microsoft.com)
Date: 03/31/04


Date: Wed, 31 Mar 2004 12:47:28 -0800

Hi Stephen,

Another possible solution if you want to come as close to load-in-place as
you can for managed code is to implement your class as a byte array with
properties that access the members. Then you can simple write the byte
array to the file and load it directly from the file.

For those who are not familiar with the term, load-in-place is a method of
mapping data in a file directly to data in memory. In C++ you would do this
by allocating a class instance and then loading a file directly into the
pointer to the instance (of course, a v-table can cause issues here).

-- 
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx
This posting is provided "AS IS" with no warranties, and confers no rights.
"stevebju" <brownst4@engr.sc.edu> wrote in message
news:108F28AE-612D-41A5-B977-9B386160E18A@microsoft.com...
> I'm having the hardest time reading and writing a simple class object to
and from a file in the CF. Could someone show me how to write a class object
to a file? Then if I have multiple objects in a file, how do I read them out
one by one?
>
> Thanks,
> Stephen


Relevant Pages

  • Arrays in Collections, Arrays in Arrays
    ... Currently I use an dummy array as a holder for a class object (acting as an ... What I would like to do is create the class object, ... Dim arrEmpty() As Variant ... Set arrMyArray1 = New Class1 ...
    (microsoft.public.vb.general.discussion)
  • Re: Passing derived class object array in place of base class object array
    ... >place of an array of base class object. ... >principle of passing a derived class reference in place of base class ...
    (comp.lang.cpp)
  • Re: VB6 Collection
    ... However, v in the array can be a built in type, UDT, class Object, or ... v in the collection can be a Variant or Class Object. ... dim obj as myClass ... object in them that have security flaws, ...
    (microsoft.public.vb.general.discussion)
  • Re: Directory Recursion and Multidimensional Arrays
    ... Have each element of the array be a class object, ... show the first set of directories. ... the next set of directories from a call to the script, ...
    (comp.lang.php)