Hi,
I'm trying a stream to sbyte conversion as follows:
But I get Invalid operation exception at the while!Code:private SByte[] streamToSbyte(Stream stream) { sbyte[] sbuffer = new sbyte[stream.Length]; byte[] buffer = new byte[stream.Length]; int read=0; try { using (MemoryStream ms = new MemoryStream()) { while (read <= 0) { read = stream.Read(buffer, 0, buffer.Length); ms.Write(buffer, 0, read); } } for (int index = 0; index < buffer.Length; index++) { sbuffer[index] = (sbyte)buffer[index]; } return sbuffer; } catch (Exception e) { Console.WriteLine("Exception caught here" + e.ToString()); return sbuffer; } }
Could anyone help please?
AK