|
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
using System.Configuration;
namespace ProxyCommon
{
internal class Common
{
public static byte[] StreamToByteArray(Stream stream)
{
List<byte> bytes = new List<byte>();
try
{
byte[] chunk = new byte[400];
int Length = stream.Read(chunk, 0, chunk.Length);
do
{
if (Length == chunk.Length)
bytes.AddRange(chunk);
else
{
byte[] tmp = new byte[Length];
Array.Copy(chunk, 0, tmp, 0, tmp.Length);
bytes.AddRange(tmp);
}
chunk = new byte[400];
Length = stream.Read(chunk, 0, chunk.Length);
}
while (Length != 0);
}
catch { }
return bytes.ToArray();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.