public static string GetString (this Stream stream) { int len = stream.GetInt (); byte [] b = new byte [len]; if (stream.Read (b, 0, len) != len) throw new IOException ("End reached"); return Encoding.UTF8.GetString (b); }