这段代码是什么意思? [英] What mean this code?

查看:209
本文介绍了这段代码是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

该代码是什么意思?

hi friends,

what mean this code?

byte[] fileNameByte = Encoding.ASCII.GetBytes(fileName);

byte[] fileData = File.ReadAllBytes(filePath + fileName);

byte[] Data = new byte[4 + fileNameByte.Length + fileData.Length];

byte[] fileNameLen = BitConverter.GetBytes(fileNameByte.Length);

fileNameLen.CopyTo(Data, 0);
fileNameByte.CopyTo(Data, 4);
fileData.CopyTo(Data, 4 + fileNameByte.Length);



特别是这段代码



specifically this code

fileNameLen.CopyTo(Data, 0);
           fileNameByte.CopyTo(Data, 4);
           fileData.CopyTo(Data, 4 + fileNameByte.Length);



谢谢



thank you

推荐答案

文件名和文件内容一起编码为1个字节数组,数组为Data
File name and the file content is encoded together in 1 array of bytes, array Data


看看 Array.CopyTo方法(Array,Int32) [
Take a look at Array.CopyTo Method (Array, Int32)[^] MSDN.


这篇关于这段代码是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆