你好,我正在将一个音频文件读入到一个字节数组中。然后我想从该字节数组中读取每4个字节的数据,并将其写入另一个文件中。
我能够做到这一点,但我的问题是,我希望在每写入4个字节的数据后添加新行。如何实现?以下是我的代码...
FileStream f = new FileStream(@"c:\temp\MyTest.acc");
for (i = 0; i < f.Length; i += 4)
{
byte[] b = new byte[4];
int bytesRead = f.Read(b, 0, b.Length);
if (bytesRead < 4)
{
byte[] b2 = new byte[bytesRead];
Array.Copy(b, b2, bytesRead);
arrays.Add(b2);
}
else if (bytesRead > 0)
arrays.Add(b);
fs.Write(b, 0, b.Length);
}
请提出您的建议。