0
WebClient web = new WebClient();
var byt = web.DownloadData(path)

This code download data very slowly even application got stuck or hang.

Mikhail Tulubaev
  • 4,141
  • 19
  • 31

2 Answers2

0

it's most likely a proxy issue. try ignoring Internet Explorer proxy settings:

WebClient web = new WebClient();
web.Proxy = null;
var byt = web.DownloadData(path)
Stavm
  • 7,833
  • 5
  • 44
  • 68
0

To prevent application hanging, it is better to use asynchronous version of DownloadData - DownloadDataAsync. Example usage can be seen at this SO question.

Simply - you should create a event handler for DownloadDataCompleted event and run DownloadDataAsync. There is no need to use async or await modifiers.

Community
  • 1
  • 1
Mikhail Tulubaev
  • 4,141
  • 19
  • 31