您目前尚未登陆,请选择【登陆】或【注册
首页->上传下载->51aspx大文件上传并显示进度和上传速率示例及组建源码>>WebbUpload/WebbRequestStream.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:51aspx大文件上传并显示进度和上传速率示例及组建源码
当前文件:文件类型 LargeFileUpload/WebbUpload/WebbRequestStream.cs打开代码结构图
普通视图
		            
1using System; 2using System.Collections; 3using System.IO; 4using System.Text; 5using System.Web; 6 7namespace Webb.WAVE.Controls.Upload 8{ 9 //该源码下载自www.51aspx.com(51aspx.com) 10 11 /// <summary> 12 /// 13 /// </summary> 14 internal class WebbRequestStream : IDisposable 15 { 16 Enums 19 20 Fields 37 38 Propetries 44 45 public WebbRequestStream() 46 { 47 this.m_fileStatus = FileStatus.Close; 48 this.m_contentTextBody = new ArrayList(); 49 this.m_tempContent = new ArrayList(); 50 this.m_tempBoundary = new ArrayList(); 51 this.m_boundaryIndex = 2; 52 this.m_contentIndex = 0; 53 this.m_content = null; 54 this.m_flag = Encoding.ASCII.GetBytes("\r\n\r\n"); 55 m_templist1 = new ArrayList(); 56 m_templist2 = new ArrayList(); 57 } 58 public void SetBoundaryFlag(byte[] i_boundaryFlag) 59 { 60 m_boundaryFlag = new byte[i_boundaryFlag.Length]; 61 i_boundaryFlag.CopyTo(m_boundaryFlag,0); 62 i_boundarySize = m_boundaryFlag.Length; 63 } 64 public void SetHttpContent(HttpContext i_content) 65 { 66 this.m_content = i_content; 67 } 68 public void SetTempPath(string i_tempPath) 69 { 70 this.m_tempPath = i_tempPath; 71 } 72 73 unsafe public void TransactReadData(byte[] m_readData) 74 { 75 ///There are 5 case when the data come in. 76 ///1. Content data, write into content. 77 ///2. Upload File data, write into file. 78 ///3. Break point at boundary, continue to find boundary. 79 ///4. Break point at contentHeader, continue to find contentHeader 80 ... 89 while(i_currentIndex<i_totalSize) 90 { 91 if(m_readData[i_currentIndex]==13||m_firstCallFunction) 92 { 93 m_firstCallFunction = false; 94 while(m_boundaryIndex<i_boundarySize&&i_currentIndex<i_totalSize) 95 { 96 search for boundary flag 105 } 106 if(m_boundaryIndex==i_boundarySize) 107 { 108 Find a boundary and not the data end. 203 } 204 } 205 if(i_currentIndex>=i_totalSize) break; 206 if(m_readData[i_currentIndex]==13) 207 { 208 If the file data contaion \r, then we should check it. 242 } 243 if(m_fileStatus==FileStatus.Open) 244 { 245 //wirte to file 255 } 256 else 257 { 258 write to context