What you want (or appear to be) is not something so trivial to do right, and goes far from the code posted. I will put a code that makes the basic practically mounted on top of the examples of the documentation but this code is not in condition to go to production.
using System.Console;
using System.Net;
using System.IO;
using System.Collections.Generic;
public class Program {
public static void Main() {
var paginas = BaixarTudo(new List<string>{"http://google.com", "http://yahoo.com"});
foreach(var pagina in paginas) {
WriteLine(pagina);
}
}
public static List<string> BaixarTudo(List<string> urls) {
var paginas = new List<string>(urls.Count);
foreach(var url in urls) {
var client = new WebClient();
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
using (var data = client.OpenRead(url)) {
using (var reader = new StreamReader(data)) {
paginas.Add(reader.ReadToEnd());
}
}
}
return paginas;
}
}
Behold working in the .NET Fiddle. Also put on the Github for future reference.
I could not understand what you want to do. Explain better the purpose and what is this internal error of the application.
– Maniero
I did a test with the code and it was no mistake. If you do what you want I don’t know why I didn’t understand the goal but the code really doesn’t do anything useful. https://dotnetfiddle.net/OYDNCi
– Maniero
type I want when finished downloading the first Webclient automatically start the other download!
– FRNathan13