public void DownloadFile(string url, song fileName) { var bgThread = new Thread(() => { _sw = new Stopwatch(); _sw.Start(); using (var webClient = new WebClient()) { webClient.Headers.Add("User-Agent: Other"); webClient.DownloadFileCompleted += DownloadCompleted; webClient.DownloadProgressChanged += DownloadStatusChanged; if (_sortArtist) { var ArtistPath = _path + "\\" + HelperClass.CleanFileName(fileName.Artist); System.IO.Directory.CreateDirectory(ArtistPath); webClient.DownloadFileAsync(new Uri(url), ArtistPath + "\\" + HelperClass.CleanFileName(fileName.GetSongInfo()) + ".mp3"); } else { webClient.DownloadFileAsync(new Uri(url), _path + fileName.GetSongInfo() + ".mp3"); } } }); bgThread.Start(); }
private void btOK_Click(object sender, EventArgs e) { if (tbKey.Text.Length > 0) { var exploded = HelperClass.DecryptSong(tbKey.Text).Split('╣'); Song = new song(exploded[3], exploded[0], true, exploded[2], exploded[1]); MessageBox.Show(Song.GetSongInfo()); } }
public void AddItemsListview(song itemSong) { var item1 = new ListViewItem(itemSong.Artist); item1.SubItems.Add(itemSong.Songname); item1.SubItems.Add("Not Started yet"); listView1.Items.Add(item1); listView1.Items[_downloadIndex].ForeColor = Color.Orange; ; _downloadQueue.Add(itemSong); lbTotalSongs.Text = "Total: " + listView1.Items.Count; if (downloading == false) { DownloadFile(itemSong.URL, itemSong); downloading = true; } }