WebClient and HttpWebRequest crashes while downloading big file on Windows Phone 7 -


i've tried both webclient , httpwebrequest download file size of 381mb through wi-fi connection or tethered. kept crashes (no error nor exception). works on file size 194mb. way download big files? or there limitation of file size downlod on windows phone 7? thanks.

for httpwebrequest: request.begingetresponse() never 'call back'; webclient: downloadprogresschanged responding well, crashes before openreadcompleted. same code working fine when file smaller, such as, 194mb.

here code webclient:

   webclient wc = new webclient();    wc.downloadprogresschanged += ((s, e) =>    {        updateprogress(e.bytesreceived, e.totalbytestoreceive);    });     wc.openreadcompleted += delegate(object sender, openreadcompletedeventargs e)    {        if (e.error == null)        {            using (var storeiso = isolatedstoragefile.getuserstoreforapplication())            {                if (e.result.length < storeiso.availablefreespace)                {                    if (storeiso.fileexists(localfilepath))                       storeiso.deletefile(localfilepath);                     using (var fs =                            new isolatedstoragefilestream(localfilepath,                           filemode.create, storeiso))                    {                       int bytesread;                       byte[] bytes = new byte[1024 * 1024 * 1]; // 1meg                       while ((bytesread =                           responsestream.read(bytes, 0, bytes.length)) != 0)                       {                         fs.write(bytes, 0, bytesread);                       }                       fs.flush();                     }                }            }        }    };     wc.openreadasync(     new system.uri(downloadfilepath, system.urikind.relativeorabsolute)); 

where updateprogress calculate percentage. when tried on file size 381 mb, app crashes before openreadcompleted called. similar when tried httpwebrequest, call assigned request.begingetresponse() not called file size of 381mb.

for smaller file size, works fine either webclient or httpwebrequest. seems me there 'memory' limitation in handing downloaded file app?

yes, there memory restrictions on platform. monitoring these? (see http://blogs.msdn.com/b/mikeormond/archive/2010/12/16/monitoring-memory-usage-on-windows-phone-7.aspx details on how so.)

you want consider using multiple requests (with range header) download large files. in addition avoiding memory restrictions allow users stop app part way through download , restart later without having restart download.
i've used technique download files 2.5gb on phone.


Comments