文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Make webclient support upload the large file which are larger than 1G

Make webclient support upload the large file which are larger than 1G

时间:2011-04-08  来源:skyfei

step1: reconstruct the WebClient class

 

public class MyWebClient : WebClient
    {
        protected override WebRequest GetWebRequest(Uri address)
        {
            HttpWebRequest request = base.GetWebRequest(address) as HttpWebRequest;
            request.Timeout = -1;
            request.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
            request.AllowWriteStreamBuffering = false;
            return request;
        }
    }

Step2: use new WebClient as the WebClient

 

                WebClient web = new MyWebClient();
                web.UploadFileCompleted += new UploadFileCompletedEventHandler(web_UploadFileCompleted);
                web.UploadProgressChanged += new UploadProgressChangedEventHandler(web_UploadProgressChanged);
                FileInfo fi = new FileInfo(@"D:\VirtualBox VMs\VMxp\VMxp.vdi");
                Uri uri = new Uri("http://127.0.0.1:9090/upload");
                web.UploadFileAsync(uri, fi.FullName);

 

 

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载