-1

What's wrong with this? I get the exception

An unhandled exception of type 'System.Net.WebException' occurred in System.dll

Additional information: An exception occurred during a WebClient request."

Here's the part of the code with the WebClient.

I need to learn how to use the code part properly one day....

http://pastebin.com/1Z90bvqB

Any answers are greatly appreciated.

Arnab Nandy
  • 6,472
  • 5
  • 44
  • 50

1 Answers1

0

(I'm not sure I agree with the ethics of the code itself, but ignoring that...) a WebException is caused by a line that connects to the internet, so either one of the lines like:

webClient.DownloadFile(String.Copy(WeepCraft), @"%appdata%\.minecraft\versions");

Or the line:

Process.Start("http://www.wirez.cf/");

In the latter case, unless I'm misunderstanding, is this actually a process you can start??

Anyway, around all the lines, you'll need to have a try/catch for WebException in case it can't connect for whatever reason (eg Internet down, wrong URL used, server returns HTTP Error code etc etc), and decide how to handle it.

It's a pretty common Exception whenever something tries to do a http request and the server can't be connected to for whatever reason.

David E
  • 1,384
  • 9
  • 14