private void Btn_Up(object sender, MouseEventArgs e) { try { recorder.RecStop(); }catch (NullReferenceException) {} recorder = null; //Boolean flag=false; string voiceStr = Post(Application.StartupPath + "\\test.wav"); if (!voiceStr.Contains("3301")) { if (voiceStr.Contains("关闭")) { Play("欢迎下次使用!"); //主程停止1秒 Thread.Sleep(1500); //该方法会强制进程关闭,并给操作系统一个退出代码。 Environment.Exit(0); //调用 Application.Exit() 并不一定能让程序立即退出,程序会等待所有的前台线程终止后才能真正退出。 //Application.Exit(); } string flag = ToolClass.openBrowser(voiceStr); if (flag == "") { textBox1.Visible = true; //textBox1.Text = voiceStr + ":未包含定义的字符!"; textBox1.Text = "指令未包含定义的字符!"; } else { textBox1.Text = "已打开" + flag; } } else { textBox1.Visible = true; textBox1.Text = voiceStr; } button1.Text = "按住说话"; button1.BackColor = Color.FromArgb(255, 255, 255); string text = textBox1.Text; Play(text); }