Question: Alter this C# code so it can be able to tell the bytes in the headers of .wav files beyond 46 bytes. The code should
Alter this C# code so it can be able to tell the bytes in the headers of .wav files beyond 46 bytes. The code should just return the bytes of wav's header.
static void Main(string[] args) { byte[] bytes = new byte[4]; FileStream fileStream = new FileStream(args[0], FileMode.Open, FileAccess.Read); fileStream.Seek(16, 0); fileStream.Read(bytes, 0, 4); fileStream.Close(); int Subchunk1Size = BitConverter.ToInt32(bytes, 0); if (Subchunk1Size < 16) Console.WriteLine("This is not a valid wav file"); else switch (Subchunk1Size) { case 16: Console.WriteLine("44-byte header"); break; case 18: Console.WriteLine("46-byte header"); break; default: Console.WriteLine("Header contains extra data and is larger than 46 bytes"); break; } } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
