C#进程调用Oracle的imp或exp

项目中有需要调用Oracle的imp或exp进程的地方,不想用存储过程,试用Process调用执行,直接上代码:

                  //备份程序命令名称
                    string strEXEName = @"exp";

                    //备份程序的参数字符串
                    string strCmdParam = @"dview/dview@" + strDBname + " file ="+"\'" + strFileParam +"\'"+ " owner=dview log=" + "\'"+strLogname+"\'";

                    //创建进程,并把备份程序的相关参数赋值给该进程
                    System.Diagnostics.Process proc = new System.Diagnostics.Process();

                    proc.StartInfo.FileName = strEXEName;

                    proc.StartInfo.Arguments = strCmdParam;

                    //运行进程
                    proc.Start();

                    //添加进程退出响应事件
                    //*proc.Exited += new EventHandler(MyProcessExited);

                    //设置进程退出事件执行的参数
                    proc.EnableRaisingEvents = true;
                   
                    proc.SynchronizingObject = null;
                   
                    //MessageBox.Show("Waiting for the process 'mspaint' to exit....");
                    //等待进程退出
                    proc.WaitForExit();

                    //进程关闭
                    proc.Close();

posted @ 2011-09-21 23:28  明基奶茶  阅读(1299)  评论(0编辑  收藏  举报