I want to write a structure consisting of fixed-length strings to a file using My.Computer.FileSystem.WriteAllBytes or the like.
I am using a VB6 project with fixed length strings that I converted to VB.Net.
Structure Record
<VBFixedString(22),System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,SizeConst:=22)> Public tim() As Char
<VBFixedString(130),System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,SizeConst:=130)> Public des() As Char
<VBFixedString(2),System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,SizeConst:=2)> Public crlf() As Char
End Structure
Still new for sorting in C #, but how can I get this structure into an array of bytes for writing to a file. Is there any marshalling trick or will I have to write my own method?
source
share