C# winform 怎样打开相对路径下面的外部程序?

解决方案 »

  1.   

     public void OpenCmd(string ServerName ,  string  UserName ,string Pass )
            {
                Process info = new Process();
                info.StartInfo.FileName = @"c:\Windows\System32\cmd.exe";
                info.StartInfo.WorkingDirectory = @"C:\";
                info.StartInfo.UseShellExecute = false;
                info.StartInfo.RedirectStandardInput = true;   //重定向标准输入
                info.StartInfo.RedirectStandardOutput = true;  //重定向标准输出
                info.StartInfo.RedirectStandardError = true;   //重定向错误输出
                info.StartInfo.CreateNoWindow = false;    
                info.Start();            string path = @"net use   \\"+ ServerName+ textBox1.Text +@"LCAPP /User:"+  UserName +" "+ Pass+"";
                info.StandardInput.WriteLine(path);
                info.StandardInput.WriteLine("Exit");
                info.Close();
            } 我在网上找的,不知道对不对,你看看吧
      

  2.   

    http://edu.codepub.com/2010/0805/24867_3.php
      

  3.   

    Process.Start("YourExeFile.exe")
    即可
      

  4.   

    Process info = new Process();
    p.StartInfo.FileName = Application.StartPath+@"";
    p.StartInfo.WorkingDirectory = @"";
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.CreateNoWindow = false;    
    p.Start();
    System.Environment.CurrentDirectory  
    获取和设置当前目录(该进程从中启动的目录)的完全限定目录。  
    System.IO.Directory.GetCurrentDirectory()  
    获取应用程序的当前工作目录。
    System.AppDomain.CurrentDomain.BaseDirectory  
    获取程序的基目录。  
      

  5.   

    以上的都行。!主要用到的类是Process。关于它的使用你可以查看MSDN