public override void Write(byte[] buffer, int index, int count) { uint bytesWritten; if (count > 0) { byte[] b = buffer; if (index != 0) { b = new byte[buffer.Length - index]; buffer.CopyTo(b, 0); } comStream.Write(b, (uint)count, out bytesWritten); if (bytesWritten != count) throw new IOException("Didn't write enough bytes to IStream!"); // @TODO: Localize this. if (index != 0) { b.CopyTo(buffer, index); } } }