BinaryReader fin = new BinaryReader( File.OpenRead( file ));
fin.Read((byte[])fileHeader, 0, Marshal.SizeOf(fileHeader));
// were fileHeader is an instance of the struct
[.net] C# struct to byte[]
hey guys,
Im tring to a struct of mine so i can stream in data from a binary file...
heres what i got
the error is that it cannot convert the struct to a byte[]..
any help here would be great
thanks
You probably need a Binary Formatter to deserialize the data. But that will only work if the data stored in the file is serialized by the same formatter.
http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.formatters.binary.binaryformatter.aspx
Greetings.
EDIT: This is probably not what you need.
[Edited by - Limitz on August 24, 2006 9:38:19 PM]
http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.formatters.binary.binaryformatter.aspx
Greetings.
EDIT: This is probably not what you need.
[Edited by - Limitz on August 24, 2006 9:38:19 PM]
That was certainly interesting, but its not really what im looking for... at least I dont want to do that to solve this issue ;p
thanks anyhow
thanks anyhow
I found a site that describes a few solutions to your problem:
http://dotnetjunkies.com/Article/DF6E5BE5-BCB6-43BB-BEE4-1013A2E3D085.dcik
Forget my previous post (it is very late here :) )
Greetings.
http://dotnetjunkies.com/Article/DF6E5BE5-BCB6-43BB-BEE4-1013A2E3D085.dcik
Forget my previous post (it is very late here :) )
Greetings.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement