long p =0; if(Request.Headers["Range"]!=null) { Response.StatusCode =206; p =long.Parse( Request.Headers["Range"].Replace("bytes=","").Replace("-","")); } if(p !=0) { Response.AddHeader("Content-Range","bytes "+ p.ToString() +"-"+ ((long)(dataToRead -1)).ToString() +"/"+ dataToRead.ToString()); } Response.AddHeader("Content-Length",((long)(dataToRead-p)).ToString()); Response.ContentType ="application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment; filename="+ System.Web.HttpUtility.UrlEncode(Request.ContentEncoding.GetBytes(filename)));
iStream.Position = p; dataToRead = dataToRead - p; // Read the bytes. while (dataToRead >0) { // Verify that the client is connected. if (Response.IsClientConnected) { // Read the data in buffer. length = iStream.Read(buffer, 0, 10240);
// Write the data to the current output stream. Response.OutputStream.Write(buffer, 0, length);
// Flush the data to the HTML output. Response.Flush();
Copyright 2001-2010, www.comprg.com.cn, All Rights Reserved 京ICP备14022230号-1,电话/传真:010-82561037 82561614 ,Mail:gaojian@comprg.com.cn
地址:北京市海淀区远大路20号宝蓝大厦E座704,邮编:100089