1、定义结构体
namespace WindowsFormsApplication1
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct fsnHead
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public UInt16[] HeadStart;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
public UInt16[] HeadString;
public UInt32 Counter;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public UInt16[] HeadEnd;
}
}
2、在方法里处理
private void button1_Click(object sender, EventArgs e)
{
string strFile = Application.StartupPath + "\\Data.dat";
FileStream fs = new FileStream(strFile, FileMode.Open, FileAccess.ReadWrite);