I would like to convert any music file into a byte array and print the result in c# just like in MATLAB.
I tried this;
System.IO.FileStream _FileStream = new System.IO.FileStream(_FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.IO.BinaryReader _BinaryReader = new System.IO.BinaryReader(_FileStream);
long _TotalBytes = new System.IO.FileInfo(_FileName).Length;
_Buffer = _BinaryReader.ReadBytes((Int32)_TotalBytes);
And the code to print to console:
Console.WriteLine( byteArrayToString(fileToByteArray("Penguins.jpg")) );
where the method's code is:
private static string byteArrayToString(byte[] p)
{
string result = System.Text.ASCIIEncoding.ASCII.GetString(p);
return result;
}
When I run this code, console becomes crazy with irrelevant characters, however I would like to have an array like MATLAB's output.
How should I do that ?
Thanks.
File.ReadAllBytes(_FileName)...