{"action":"created","issue":{"url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/3630","repository_url":"https://api.github.com/repos/xamarin/Xamarin.Forms","labels_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/3630/labels{/name}","comments_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/3630/comments","events_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/3630/events","html_url":"https://github.com/xamarin/Xamarin.Forms/issues/3630","id":352819287,"node_id":"MDU6SXNzdWUzNTI4MTkyODc=","number":3630,"title":"WebClient TotalBytesToReceive always Returns -1","user":{"login":"yanshouwang","id":24455689,"node_id":"MDQ6VXNlcjI0NDU1Njg5","avatar_url":"https://avatars2.githubusercontent.com/u/24455689?v=4","gravatar_id":"","url":"https://api.github.com/users/yanshouwang","html_url":"https://github.com/yanshouwang","followers_url":"https://api.github.com/users/yanshouwang/followers","following_url":"https://api.github.com/users/yanshouwang/following{/other_user}","gists_url":"https://api.github.com/users/yanshouwang/gists{/gist_id}","starred_url":"https://api.github.com/users/yanshouwang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yanshouwang/subscriptions","organizations_url":"https://api.github.com/users/yanshouwang/orgs","repos_url":"https://api.github.com/users/yanshouwang/repos","events_url":"https://api.github.com/users/yanshouwang/events{/privacy}","received_events_url":"https://api.github.com/users/yanshouwang/received_events","type":"User","site_admin":false},"labels":[{"id":771881931,"node_id":"MDU6TGFiZWw3NzE4ODE5MzE=","url":"https://api.github.com/repos/xamarin/Xamarin.Forms/labels/s/needs-info%20%E2%9D%93","name":"s/needs-info ❓","color":"fcb95a","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-08-22T06:29:45Z","updated_at":"2018-09-07T17:33:09Z","closed_at":null,"author_association":"NONE","body":"<!-- Bug report best practices: https://github.com/xamarin/Xamarin.Forms/wiki/Submitting-Issues -->\r\n\r\n### Description\r\nafter i upgraded to VS 2017 15.8, the DownloadProgressChanged event of WebClient occured an error that  the e.TotalBytesToReceive parameter always returns -1, and it's work fine before i upgraded and in my workmate's VS 2017 15.7.\r\n### Steps to Reproduce\r\n\r\nThe follow is my code:\r\n`\r\n               DownloadProgress = 0;\r\n\r\n                // After upgrade to VS 2017 15.8.0 TotalBytesToReceive always Returns -1\r\n                using (var client = new WebClient())\r\n                {\r\n                    client.DownloadProgressChanged += (s, e) =>\r\n                    {\r\n                        DownloadProgress = (double)e.BytesReceived / e.TotalBytesToReceive;\r\n                    };\r\n\r\n                    await client.DownloadFileTaskAsync(_otaUri, tempPath);\r\n                }\r\n                return true;\r\n\r\n                //using (var client = new HttpClient())\r\n                //using (var stream = await client.GetStreamAsync(_otaUri))\r\n                //using (var fs = new FileStream(tempPath, FileMode.Append))\r\n                //{\r\n                //    var totalBytes = stream.Length;\r\n                //    var receivedBytes = 0;\r\n                //    var readBytes = 0;\r\n                //    var buffer = new byte[102400];\r\n\r\n                //    while ((readBytes = await stream.ReadAsync(buffer, 0, buffer.Length)) > 0)\r\n                //    {\r\n                //        fs.Write(buffer, 0, readBytes);\r\n                //        receivedBytes += readBytes;\r\n                //        DownloadProgress = (double)receivedBytes / totalBytes;\r\n                //    }\r\n                //    fs.Flush();\r\n                //    fs.Close();\r\n                //}\r\n                //return true;\r\n`\r\nI also try to use HttpClient but the buffer length confused me...\r\nI will open that file immediately after i download my apk file, but if I use the fileStream and the download speed is to fast the bag will not be readable right now\r\nAnd the WebClient works very well except can't read the whole length...\r\nAny suggestions to me or What can I do to fix that?\r\n\r\n### Expected Behavior\r\nThe e.TotalByteToReceive returns the file's real length.\r\n### Actual Behavior\r\nalways returns -1\r\n### Basic Information\r\n\r\n- Version with issue: VS 2017 15.8\r\n- Last known good version: VS 2017 15.7\r\n- IDE: Visual Studio Comunity\r\n- Platform Target Frameworks: <!-- All that apply -->\r\n  - iOS:  11.4\r\n  - Android: 8.1\r\n  - UWP:  NULL\r\n- Android Support Library Version: <!-- if applicable -->\r\n- Nuget Packages:\r\n- Affected Devices:\r\n\r\n### Screenshots\r\n\r\n![youdu 20180822142703](https://user-images.githubusercontent.com/24455689/44446528-cab33180-a617-11e8-9f17-7b780c24f5f8.png)\r\n\r\n### Reproduction Link\r\n\r\n<!-- Please upload or provide a link to a reproduction case -->\r\n"},"comment":{"url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/comments/419511804","html_url":"https://github.com/xamarin/Xamarin.Forms/issues/3630#issuecomment-419511804","issue_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/3630","id":419511804,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTUxMTgwNA==","user":{"login":"Sebastian1989101","id":25636075,"node_id":"MDQ6VXNlcjI1NjM2MDc1","avatar_url":"https://avatars0.githubusercontent.com/u/25636075?v=4","gravatar_id":"","url":"https://api.github.com/users/Sebastian1989101","html_url":"https://github.com/Sebastian1989101","followers_url":"https://api.github.com/users/Sebastian1989101/followers","following_url":"https://api.github.com/users/Sebastian1989101/following{/other_user}","gists_url":"https://api.github.com/users/Sebastian1989101/gists{/gist_id}","starred_url":"https://api.github.com/users/Sebastian1989101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sebastian1989101/subscriptions","organizations_url":"https://api.github.com/users/Sebastian1989101/orgs","repos_url":"https://api.github.com/users/Sebastian1989101/repos","events_url":"https://api.github.com/users/Sebastian1989101/events{/privacy}","received_events_url":"https://api.github.com/users/Sebastian1989101/received_events","type":"User","site_admin":false},"created_at":"2018-09-07T17:33:09Z","updated_at":"2018-09-07T17:33:09Z","author_association":"NONE","body":"@pauldipietro I did not change any NuGet package what so ever. The last time I upgrade my NuGet packages is 3 month ago and it has worked until the VS 2017 update to 15.8. "}}
{"actor":{"display_login":"Sebastian1989101"}}