So far Ive got a function that reads in all the bytes using ReadBytes(). I want to use all to data and add it to my 'arrfile' which is a byte[].
private byte[] GetWAVEData(string strWAVEPath)
{
FileStream fs = new FileStream(@strWAVEPath, FileMode.Open, FileAccess.Read);
byte[] arrfile = new byte[fs.Length - 44];
fs.Position = 4;
// fs.Read(arrfile, 0, arrfile.Length);
for (int i = 0; i < arrfile.Length; i++)
{
int b = fs.ReadByte();
}
fs.Close();
return arrfile;
}
I have used 'b' to read in all the bytes from the fileStream, now how do I put each value for 'b' into the 'arrfile' that is a byte[], using the loop?
Thanks for all the answers, I got it working using:
private byte[] GetWAVEData(string strWAVEPath)
{
FileStream fs = new FileStream(@strWAVEPath, FileMode.Open, FileAccess.Read);
byte[] arrfile = new byte[fs.Length - 44];
fs.Position = 44;
for (int i = 0; i < arrfile.Length; i++)
{
int b = fs.ReadByte();
byte convert = Convert.ToByte(b);
arrfile[i] = convert;
}
fs.Close();
return arrfile;
}