Nadav,
While this certainly could be acheived using ISerializable, there is no
point in doing so. ISerializable's purpose is to implement custom
serialization - so that IFormatter (BinaryFormatter for example), can call
the proper constructor and the proper GetObjectData - in your case you are
probably better off implementing the "deserialization" to .NET via a non
ISerializable or Serializable mechanism.
Secondly,
Kernel32.Dll->CreateFileMapping and
Kernel32.Dll->MapViewOfFile ..
AFAIK donot have managed implementations.
But they can be easily used in C# like this --
[DllImport("kernel32.dll", SetLastError=true)]
static extern IntPtr CreateFileMapping(IntPtr hFile,
IntPtr lpFileMappingAttributes, PageProtection flProtect, uint
dwMaximumSizeHigh,
uint dwMaximumSizeLow, string lpName);
and
[DllImport("kernel32.dll")]
static extern IntPtr MapViewOfFile(IntPtr hFileMappingObject, uint
dwDesiredAccess, uint dwFileOffsetHigh, uint dwFileOffsetLow,
UIntPtr dwNumberOfBytesToMap);
TTFN :-)
- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
"Nadav" <(E-Mail Removed)> wrote in message
news:F6964180-F032-431B-B09A-(E-Mail Removed)...
> Hi,
>
> I have to read files generated by 3rd party application, these files are
> in
> a propriotary format ( not generated using the .NET framework ), I want to
> implement a custom DeSerializer to read the data in the file, I wonder is
> it
> possible to read files in this manner ( e.g. custom implementation of the
> ISerializable interface )? is this right way to extract data from the
> file?
> OR should I rather 'manually' use the FileStream to read the desiered
> chunks
> of data?
>
> Another Issue, is there a C# equivalent to the unmanaged
> CreateFileMapping,
> ??? accessing files in this manner dramatically impove
> performance as the kernel is resposible for loading the data from the disk
> (
> and not the application ) so less context switch are done between the
> application layer and the kernel...
>
> --
> Nadav
> http://www.ddevel.com