Esempio n. 1
0
 private void BrowseButton_Click(object sender, EventArgs e)
 {
     if (OpenWavFilesDialog.ShowDialog() == DialogResult.OK)
     {
         TotalFiles.Text = "Total Files = " + OpenWavFilesDialog.FileNames.Length.ToString();
     }
 }
Esempio n. 2
0
 private void ConvertButton_Click(object sender, EventArgs e)
 {
     if (OpenWavFilesDialog.FileNames.Length > 0 && SaveMP3FolderBrowserDialog.SelectedPath != "")
     {
         progressBar1.Visible         = true;
         BrowseButton.Enabled         = false;
         SaveAsButton.Enabled         = false;
         BitrateComboBox.Enabled      = false;
         SamplingrateComboBox.Enabled = false;
         ConvertButton.Enabled        = false;
         try
         {
             progressBar1.Maximum = OpenWavFilesDialog.FileNames.Length;
             textBox1.Text        = "-";
             foreach (string fn in OpenWavFilesDialog.FileNames)
             {
                 ProcessStartInfo psi = new ProcessStartInfo();
                 psi.UseShellExecute       = false;
                 psi.CreateNoWindow        = true;
                 psi.WindowStyle           = ProcessWindowStyle.Hidden;
                 psi.RedirectStandardError = true;
                 psi.FileName  = Application.StartupPath + @"\lame.exe";
                 psi.Arguments = "-b" + BitrateComboBox.SelectedItem.ToString() + " --resample " + SamplingrateComboBox.SelectedItem.ToString() + " -m j " +
                                 "\"" + fn + "\"" + " " +
                                 "" + "--priority 3" + " " +
                                 "\"" + SaveFilesPath.Text + "\\" + Path.GetFileNameWithoutExtension(fn) + ".mp3" + "\"";
                 Process p = Process.Start(psi);
                 //string stdoutx = p.StandardOutput.ReadToEnd();
                 string stderrx = p.StandardError.ReadToEnd();
                 textBox1.Text = textBox1.Text + "\n\r" + stderrx;
                 p.WaitForExit();
                 p.Close();
                 p.Dispose();
                 progressBar1.Value = progressBar1.Value + 1;
                 Thread.Sleep(1000);
                 if (progressBar1.Value == progressBar1.Maximum)
                 {
                     MessageBox.Show(OpenWavFilesDialog.FileNames.Length + " File(s) Converted Successfully", "Success");
                     progressBar1.Visible = false;
                     progressBar1.Value   = 0;
                     TotalFiles.Clear();
                     BrowseButton.Enabled = true;
                     SaveFilesPath.Clear();
                     SaveAsButton.Enabled         = true;
                     BitrateComboBox.Enabled      = true;
                     SamplingrateComboBox.Enabled = true;
                     ConvertButton.Enabled        = true;
                     OpenWavFilesDialog.Reset();
                     SaveMP3FolderBrowserDialog.Reset();
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
     else
     {
     }
 }