Description
Download multiple files using webclient DownloadFileAsync and use a text file to enter the URL to download.
Problem
The approach that I used will not upload files at all. Just running and doing nothing. It fills the list array and then exits without loading a single file. I googled for solutions, but came up with a short one. Then I tried to find a solution in the database here with the same results. Any help is appreciated.
Questions
- Why does this approach not work?
- What can I do to improve this and learn from it.
code
DownloadClass.cs
using System; using System.ComponentModel; using System.Collections.Generic; using System.Net; using System.Threading; using System.Windows.Forms; namespace ThreadTest { class DownloadClass { public struct download { public static string URL { get; set; } public static string file { get; set; } public static string[] link; public static int downloadcount; } public static List<string> list = new List<string>(); public static WebClient wc = new WebClient(); public static void Download() { int count = 0; download.URL = list[0]; Uri URI = new Uri(download.URL); UriBuilder uri = new UriBuilder(URI); download.link = uri.Path.ToLower().Split(new char[] { '/' }); count = 0;
Program.cs (Main Class)
using System; using System.IO; using System.Collections.Generic; using System.Windows.Forms; namespace ThreadTest { class Program { static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("Usage: {0} <download txtfile>", Environment.GetCommandLineArgs()[0]); Environment.Exit(0); } int counter = 0; string line; string format = string.Format("{0}\\{1}", Application.StartupPath, args[0]);
source share