2011年10月小记

1、chunked输出

            string path = Server.MapPath("file2.jpg");

var buffer = File.ReadAllBytes(path);

int size = 8192;
byte[] data;
int pos = 0;
for (int i = 0; i < buffer.Length / size; i++)
{
data = new byte[size];
pos = i * size;
Array.Copy(buffer, pos, data, 0, data.Length);
Response.OutputStream.Write(data, 0, data.Length);
Response.OutputStream.Flush();
}

data = new byte[buffer.Length % size];
Array.Copy(buffer, pos + size, data, 0, data.Length);
Response.OutputStream.Write(data, 0, data.Length);
Response.OutputStream.Flush();



你可能感兴趣的:(2011年10月小记)