最近我研究了一下怎样实现 绑定 数据上传过程中的真实进度问题我自己有个上传方法,其中采用的不是直接saveas(),
而是采用了byte数据流的方式,代码如下:
 string uploadPath = Server.MapPath("Ebook\\" + ebookname);//上传路径               FileStream fs = new FileStream(uploadPath, FileMode.Create);            BinaryWriter bw = new BinaryWriter(fs);            byte[] buffer = new Byte[10000];            while (contentLength > 0)
            {
                // Read the data in buffer.
                int length = FileUpload1.PostedFile.InputStream.Read(buffer, 0, 10000);
                // Write the data to the current output stream.
                bw.Write(buffer, 0, length);                buffer = new Byte[10000];                contentLength = contentLength - length;
/////////////label.text=contentLength ;
                                             
            }            fs.Close();            bw.Close();
请仔细看,这个方法实际上是放在了一个委托方法内的,通过按扭的点击来触发委托事件、
delegate void ShowProgressDelegate();ShowProgressDelegate showProgress = new ShowProgressDelegate(Progress);showProgress.Invoke();一开始的时候本来我是想用backgroundworker类的异步方式来显示进度,就是在红色部分的label内显示字节数;可是执行的时候,出错,显示,不是ui线程不可以调用此线程以外的ui线程内的控件所以我通过查找资料,知道,可以把所有由线程(无论是什么线程)来完成的任务交给委托,所以我采用了上边的方式可是依然没效果,就是说,只要是在while循环内,窗体上的label上就不能象winform程序一样时时刷新进度,后来我想,是不是页面刷新问题呢?所以我有在label外套了一个updatepanel,可是,还是不行。
请大神帮帮忙拉,我就是想时时显示进度(是真实进度),小弟不常来上网,分比较少,请多多担待,谢谢