) and file path(\"F:\\Android\\apache-ant-1.8.2-bin\\apache-ant-" />
开发者

Related to ProcessStartInfo() method in C#

开发者 https://www.devze.com 2023-02-17 02:35 出处:网络
I want to give command name and file path in ProcessStartInfo() method in C#. So I have a command name(\"F:\\AndroidProjects\\AndProj3>) and file path(\"F:\\Android\\apache-ant-1.8.2-bin\\apache-ant-

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

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.

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;
    }

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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号