相关的ProcessStartInfo()在C#中的方法 [英] Related to ProcessStartInfo() method in C#

查看:2736
本文介绍了相关的ProcessStartInfo()在C#中的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想给命令名称和的ProcessStartInfo()文件路径在C#中的方法

I want to give command name and file path in ProcessStartInfo() method in C#.

所以我有一个命令名(F:\AndroidProjects\ AndProj3>)和文件路径(F:\Android\apache-ANT-1.8.2-bin\apache-ANT-1.8.2\bin\ant调试)就是这样,但它不工作和工艺无法启动。

So I have a command name("F:\AndroidProjects\AndProj3>) and file path("F:\Android\apache-ant-1.8.2-bin\apache-ant-1.8.2\bin\ant debug") just like that but it is not working and process can not be started.

请给我一个解决方案,用于启动过程,因为命令名称先执行,之后的文件路径将会执行。
如何我可以传递的ProcessStartInfo两个参数()方法?

Please give me a solution for starting the process because command name first execute and after that file path will be execute. How I can pass the both argument in ProcessStartInfo() method?

public static string BuildAndroidProject()
    {
        string result="";
      //  string ProjNameNDLocation = ProjectLocation + "\\" + ProjectName + ">";
        try
        {

            System.Diagnostics.ProcessStartInfo androidBuildProj = new System.Diagnostics.ProcessStartInfo("F:\\AndroidProjects\\AndProj3 F:\\Android\\apache-ant-1.8.2-bin\\apache-ant-1.8.2\\bin\\ant debug");//ProjNameNDLocation, Program.ANDROIDDEBUGGCMD);
            androidBuildProj.RedirectStandardOutput = true;
            androidBuildProj.UseShellExecute = false;
            androidBuildProj.CreateNoWindow = true;
            System.Diagnostics.Process androidProcess = new System.Diagnostics.Process();
            androidProcess.StartInfo = androidBuildProj;
            androidProcess.Start();
           result = androidProcess.StandardOutput.ReadToEnd();
            androidProcess.Close();

        }
        catch (Exception e)
        {

        }
        return result;
    }



问题是在 ProcessInfoStart 功能。 ?我怎样才能运行此命令。

Problem is in the ProcessInfoStart Function. How can I run this command?

推荐答案

根据这个问题,我可以看到最接近的是:

Based on the question, the closest I can see is:

using (var proc = Process.Start(new ProcessStartInfo
{
    WorkingDirectory = @"F:\AndroidProjects\AndProj3",
    FileName = @"F:\Android\apache-ant-1.8.2-bin\apache-ant-1.8.2\bin\ant",
    Arguments = "debug"
}))
{
   // maybe wait and check exit-code
   // proc.WaitForExit();
   // int i = proc.ExitCode;
}

这篇关于相关的ProcessStartInfo()在C#中的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆