日期:2014-05-19  浏览次数:20910 次

C#调用cmd.exe程序,怎么启动不了?
初学C#语言,不是很懂,请高人指点!!先谢谢了!!!
这里我要备份数据库,调用CMD,用命令方法备份,我代码如下,但是运行后发现CMD没有启动,是什么原因啊??
                sqlbf();
                //sqlbf   dbop   =   new   sqlbf();
                //dbop.DbBackup();
                string   path   =   CreatePath();

                string   ls_dmp   =   CreatePath()   +   ".dmp ";
                string   ls_log   =   CreatePath()   +   ".log ";
                string   ls_name   =   uid;
                string   ls_pwd   =   pwd;
                string   ls_tns   =   server;
                string   ls_cmd   =   "exp   "   +   ls_name   +   "/ "   +   ls_pwd   +   "@ "   +   ls_tns   +   "   file= "   +   ls_dmp   +   "   log= "   +   ls_log   +   "   owner=(gdzc) ";

                //开始创建文件  
                try
                {
                        Process   p   =   new   Process();
                        p.StartInfo.FileName   =   "cmd.exe ";
                        p.StartInfo.UseShellExecute   =   false;
                        p.StartInfo.RedirectStandardInput   =   true;
                        p.StartInfo.RedirectStandardOutput   =   true;
                        p.StartInfo.RedirectStandardError   =   true;
                        p.StartInfo.CreateNoWindow   =   true;
                        p.Start();
                        p.StandardInput.WriteLine(ls_cmd);
                        p.StandardInput.WriteLine( "exit ");
                        //string   ls_ret   =   p.StandardOutput.ReadToEnd();

                        Label1.Text   =   "提示:数据库备份成功! ";
                        Response.Write( " <script> alert( ' "   +   Label1.Text   +   " '); </script> ");