获取文件数据流+叠加byte数组(给byte数组加包头包尾)

 OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "(*.mp4)|*.mp4|(*.*)|*.*";
ofd.RestoreDirectory = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
try
{ // 打开文件 FileStream fileStream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.Read); // 读取文件的 byte[] byte[] brecord = new byte[fileStream.Length];
fileStream.Read(brecord, , brecord.Length);
byte[] data1 = { , , , , , , };
byte[] data2 = { , , , , , , }; var data3 = new byte[data1.Length + data2.Length + brecord.Length];
Stream s = new MemoryStream();
s.Write(data1, , data1.Length);
s.Write(brecord, , brecord.Length);
s.Write(data2, , data2.Length);
s.Position = ;
int r = s.Read(data3, , data3.Length);
if (r > )
{
//此时data3中就是合并的值了
}
mc.Send(data3); fileStream.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
//sr.Close();
//fs.Close();
}
}
上一篇:Elasticsearch Mapping


下一篇:《Mybatis编程自学与面试指南》01-10:映射器Mapper