public bool Write(string filename, short [] data) { var builder = new FlatBufferBuilder(1); var waferid = builder.CreateString("TestWafer"); var wnum = (short)1; var lotid = builder.CreateString("LotWafer"); var binFormat = format.Hex; var mapdata = MAP.CreateMapVector(builder, data); MAP.StartTargetDieVector(builder, 2); stXY.CreatestXY(builder, 22, 25); stXY.CreatestXY(builder, 23, 25); var vecTargetDie = builder.EndVector(); MAP.StartRefDieVector(builder, 2); stXY.CreatestXY(builder, 1, 5); stXY.CreatestXY(builder, 2, 5); var vecRefDie = builder.EndVector(); //var vecRefDie = builder.CreateVectors(refDieOffset); MAP.StartMAP(builder); MAP.AddMaxCol(builder, 5); MAP.AddMaxRow(builder, 2); MAP.AddMap(builder, mapdata); MAP.AddTargetDie(builder, vecTargetDie); MAP.AddRefDie(builder, vecRefDie); MAP.AddLotNum(builder, lotid); MAP.AddBincodeFormat(builder, binFormat); var mitMap = MAP.EndMAP(builder); builder.Finish(mitMap.Value); /// serialize to file /// BinaryWriter writer = new BinaryWriter(File.Open(filename, FileMode.CreateNew | FileMode.Truncate)); byte[] savebuf = builder.SizedByteArray(); writer.Write(savebuf); writer.Close(); return(true); }