c# - DownloadAsyncData of WebClient fails -
i have url in format http://ww.url.com/page?id=200. download file of 10 mb. getting e.progresspercentage 0 always. hitting upload done function actual results read.
please tell me doing wrong here.
i using following code
private void button1_click(object sender, eventargs e) { webclient webclient = new webclientex(); webclient.downloadprogresschanged += new downloadprogresschangedeventhandler(wc_downloadprogresschanged); webclient.downloaddatacompleted += new downloaddatacompletedeventhandler(wc_downloadcomplete); webclient.downloaddataasync(new uri("http://ww.url.com/page?id=200")); } public void wc_downloadprogresschanged(object sender, downloadprogresschangedeventargs e) { progress1.value = e.progresspercentage; // 0 } public void wc_downloadcomplete(object sender,downloaddatacompletedeventargs e) { int = 0; this.close(); } } }
progresspercentage based on contentlength returned in header of response. if response doesn't know how big download when putting header, won't able progress.
if file returned iis, iis size of file file system , set header you. if response dynamic , fit within buffer, length of response set. however, default buffer size less 10mb response header sent client before length of response known.
in asp.net, (where put depends on platform)...
response.addheader("content-length", "10485760");
Comments
Post a Comment