public static ReadString ( this s, |
||
s | this | |
encoding | ||
maxLength | int | |
return | string |
public static string ReadString(this Stream s, Encoding encoding, int maxLength)
{
var length = s.ReadInt32();
if (length > maxLength)
throw new InvalidOperationException("The length of the string ({0}) is longer than the maximum allowed ({1}).".F(length, maxLength));
return encoding.GetString(s.ReadBytes(length));
}