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;
}
精彩评论