Example #1
0
 private void GetSize()
 {
     new Thread(() =>
     {
         long CalcSize = 0;
         foreach (string URL in URLs)
         {
             CalcSize += DownloadsViewModel.GetFileLengthFromURL(URL);
         }
         Size = CalcSize;
     }).Start();
 }
Example #2
0
        internal DownloadEntry(string URL, string Folder, string[] URLCollection, Action <string[], object> Callback, object State)
        {
            UIContext          = SynchronizationContext.Current;
            this.URL           = URL;
            this.Callback      = Callback;
            this.State         = State;
            this.URLCollection = URLCollection;
            this.Folder        = Folder;
            Directory.CreateDirectory(Folder);
            Name = DownloadsViewModel.GetFileNameFromURL(URL);
            Uri Uri = new Uri(URL);

            Status = DownloadStatus.Downloading;
            new Thread(() =>
            {
                Size = DownloadsViewModel.GetFileLengthFromURL(URL);

                Client = new MyWebClient();
                Client.DownloadFileCompleted   += Client_DownloadFileCompleted;
                Client.DownloadProgressChanged += Client_DownloadProgressChanged;
                Client.DownloadFileAsync(Uri, Path.Combine(Folder, DownloadsViewModel.GetFileNameFromURL(Uri.LocalPath)), null);
            }).Start();
        }