用c#打开bat文件,但它立即关闭

时间:2017-07-11 13:49:08

标签: c# winforms

我想用c#打开一个bat文件。

private void button1_Click(object sender, EventArgs e)
{
    string cmd_p1 = @"ffmpeg -re -stream_loop -1 -i ";
    string strMediaSource = txtMediaSource.Text.Trim();
    string cmd_p2 = " -r 30 -c:v libx264 -x264-params keyint=60 -b:v 1000k -acodec libmp3lame -b:a 128k -ar 44100 -threads 0 -minrate 1000k -maxrate 1000k -bufsize 500k -f flv \"rtmp://rtmp-api.facebook.com:80/rtmp/";
    string strKey = txtKey.Text.Trim();

    StreamWriter sw = new StreamWriter("test.bat");
    sw.WriteLine(cmd_p1 + strMediaSource + cmd_p2 + strKey + "\"");
    sw.Close();
    Process p = new Process();
    p.StartInfo.FileName = "test.bat";
    p.Start();                       
}

但它立即关闭了。 我怎样才能让它显示出来。

0 个答案:

没有答案