private void Btn_Browse_Click(object sender, EventArgs e) { if (Txt_Url.Text.Length > 0) { if (process != null && TempFolderPath != null && TempFolderPath.Trim().Length > 0) { process.Close(); process.Dispose(); if (Directory.Exists(TempFolderPath)) { Directory.Delete(TempFolderPath, true); } } DownloadFolderPath.Description = "Select Folder to Save File"; if (DownloadFolderPath.ShowDialog() == DialogResult.OK) { Btn_Download.Enabled = true; } } else { MessageBox.Show("Please Enter Video's Url in Textbox", "Information"); Txt_Url.Focus(); } }
private void Form1_Load(object sender, EventArgs e) { LblTitle.Text = ""; lblProgress.Text = ""; Txt_Url.Focus(); SupportedFormats.Clear(); SupportedFormats.Add("Select"); //SupportedFormats.Add("Avi"); SupportedFormats.Add("Mp3"); //SupportedFormats.Add("Mp4"); //SupportedFormats.Add("Mpeg"); //SupportedFormats.Add("Wmv"); Cmb_Formats.DataSource = SupportedFormats; }
private void Btn_Download_Click(object sender, EventArgs e) { try { if (Txt_Url.Text.Length > 0) { if (process != null && TempFolderPath != null && TempFolderPath.Trim().Length > 0) { process.Close(); process.Dispose(); if (Directory.Exists(TempFolderPath)) { Directory.Delete(TempFolderPath, true); } } DownloadFolderPath.Description = "Select Folder to Save File"; DialogResult SelctPath = DialogResult.Cancel; if (DownloadFolderPath.SelectedPath == null || DownloadFolderPath.SelectedPath.Trim().Length == 0) { SelctPath = DownloadFolderPath.ShowDialog(); } else { SelctPath = DialogResult.OK; } if (SelctPath == DialogResult.OK) { if (DownloadFolderPath.SelectedPath != null || DownloadFolderPath.SelectedPath.Trim().Length != 0) { using (this.Cursor = Cursors.WaitCursor) { if (Txt_Url.Text.Length > 0) { DataGrd_VdoLst.DataSource = null; DataGrd_VdoLst.Enabled = true; lblProgress.Text = ""; PrgrsBar_Download.Value = 0; bool DownloadNow = false; if (RadBtn_DownloadConvert.Checked) { Cmb_Formats.SelectedIndex = 1; DownloadNow = true; /*if (Cmb_Formats.SelectedIndex > 0) * { * DownloadNow = true; * } * else * { * MessageBox.Show("Please Select Format To Convert Into", "Information"); * this.Cursor = Cursors.Default; * return; * }*/ } else if (RadBtn_Download.Checked) { DownloadNow = true; } if (DownloadNow) { BindGrid(); if (title != null && title.Trim().Length > 0) { if (title.Length > 70) { LblTitle.Text = title.PadRight(80, ' ').Substring(0, 70) + "...."; } else { LblTitle.Text = title; } label2.Visible = true; } } } else { MessageBox.Show("Please Enter Youtube Video URL", "Information"); } } this.Cursor = Cursors.Default; } } else { MessageBox.Show("Please Select Folder To Save The File", "Information"); } } else { MessageBox.Show("Please Enter Video's Url in Textbox", "Information"); Txt_Url.Focus(); } } catch (Exception ex) { if (ex.Message.Contains("The remote server returned an error: (404) Not Found.")) { MessageBox.Show(ex.Message); } else { Common.LogError(ex); } } }