.Net/C#: 实现支持断点续传多线程下载的 Http Web 客户端工具类 (C# DIY HttpWebClient)
http://blog.csdn.net/playyuer/archive/2005/03/06/313081.aspx调试了很多次老是在多线程下载的时候提示“未将对象引用设置到对象的实例”if (this.ExceptionOccurrs != null)
                {
                    DownLoadState x = new DownLoadState(Address, hwrp.ResponseUri.AbsolutePath, FileName, a, FromPosition, Length);//==此句报错==
                    ExceptionEventArgs eea = new ExceptionEventArgs(e, x);
                    ExceptionOccurrs(this, eea);
                    ea = eea.ExceptionAction;
                }希望大家一起讨论!

解决方案 »

  1.   

    出现这种情况,不是DownLoadState x = new DownLoadState(Address, hwrp.ResponseUri.AbsolutePath, FileName, a, FromPosition, Length);//==此句报错==
    有问题,而是if (this.ExceptionOccurrs != null)//说明已经有例外产生了.
    而产生这种情况很可能是Address有问题,也不是你输入的下址有问题.
      

  2.   

    地址应该没有错误啊,在浏览器中可以正常下载:string StrFileName = "c:\\MOV08510.MPG";   //根据实际情况设置   
                string StrUrl = "http://www.cshes.tcc.edu.tw/photo-mpg/9505/MOV08510.MPG";   //根据实际情况设置               //打开上次下载的文件或新建文件   
                long lStartPos = 0;
                System.IO.FileStream fs;
                if (System.IO.File.Exists(StrFileName))
                {
                    fs = System.IO.File.OpenWrite(StrFileName);
                    lStartPos = fs.Length;
                    fs.Seek(lStartPos, System.IO.SeekOrigin.Current);   //移动文件流中的当前指针   
                }
                else
                {
                    fs = new System.IO.FileStream(StrFileName, System.IO.FileMode.Create);
                    lStartPos = 0;
                }
      

  3.   

    看作者blog上面的评论应该有好多人有同样的问题!希望大家都试试这个代码!