public static byte[] InputStreamToArray(Stream isp) { byte[] b = new byte[8192]; MemoryStream outp = new MemoryStream(); while (true) { int read = isp.Read(b, 0, b.Length); if (read < 1) break; outp.Write(b, 0, read); } return outp.ToArray(); }