求.net多线程下载代码或者demo
回复和邮箱均可
[email protected]
如果是多线程异步下载就更好了 哇啊卡卡~~

解决方案 »

  1.   

            protected void DownloadFile(string fileLocation)
            {
                Thread thread = new Thread(delegate() { 
                    Downnload(fileName);            });
                thread.Start();
            }for(int i=0;i<3;i++)
    {
      DownloadFile(fileLocation);
    }
      

  2.   

    其实这个问题也不难。。比如你开四个线程。。你可以把文件切成四份进行下载,也就是多线程去写某个文件。。设置四个线程流的起始值
                          private  const int threadcount=4
     FileInfo  file=new FileInfo("a.bak");
                FileStream iOutPut = file.Open(FileMode.Open, FileAccess.Write, FileShare.Write); 
    iOffset = iOutPut.Length*i/4(i为当前线程起始点,iOutPut.Length/4-1);
    long iNPos = iOutPut.Seek(iOffset,SeekOrigin.Begin);//从新设置流的起始值
    然后多线程去写入这个文件