public void Write(IPtpIpCommand container) { using (MemoryStream ms = new MemoryStream()) { container.Write(ms); _inerStream.Write(ms.ToArray(), 0, (int)ms.Length); //if(container.Header.Length!=ms.Length) // throw new Exception("Wrong length"); _inerStream.Flush(); } }