The code is as follows:
The Process of p=new Process ();
P. tartInfo. FileName="pre_test \ \ pre_test exe";//need to perform file, I put him in the site directory
.//p. tartInfo FileName="CMD. Exe";//need to perform file, I put him in the site directory
P. tartInfo. UseShellExecute=false;//necessary
P. tartInfo. RedirectStandardOutput=true;//output parameters setting
P. tartInfo. RedirectStandardInput=true;//incoming parameters setting
P. tartInfo. CreateNoWindow=true;
//p. tartInfo. The Arguments="D: \ \ the PPP";//parameters separated by Spaces, if a parameter is empty, can pass in ""
.//p. tartInfo StandardErrorEncoding=System. Text.. Encoding UTF8;//incoming parameters setting
P. tart ();
P. tandardInput. WriteLine (" d: \ \ result ");
StreamReader _StreamReader=p. tandardOutput;
The string line=_StreamReader. ReadToEnd ();
String _Resultindex=line. The Substring (line. IndexOf (" [[") + 2, 6);
Console. WriteLine ($" to obtain the value of the is: {_Resultindex} ");
P.W aitForExit ();//wait for program execution of the exit process
P.C lose ();
_StreamReader. Close ();
Based on under win10 p. tandardInput didn't receive the parameters
CodePudding user response:
No one reply, frontal forehead frontal forehead has been resolvedCodePudding user response:
No more than two reasons, permissions and path problemsCodePudding user response:
CodePudding user response:
Has been resolved,,,CodePudding user response:
Internal static void startProgram ()
{
Int index=ConfigurationManager. AppSettings [r]. "exePath" Trim (), ToString (). The LastIndexOf (" \ \ ");
String filePath.=ConfigurationManager AppSettings [r]. "exePath" Trim (), ToString (). The Substring (0, index);
String exePath=ConfigurationManager. AppSettings [r]. "exePath" Trim (). The ToString ();
New Process during Process Process={StartInfo={FileName=exePath, WorkingDirectory=filePath, the Arguments="test"}};
Process. The Start ();
}
CodePudding user response:
The string line=_StreamReader. ReadToEnd ();String _Resultindex=line. The Substring (line. IndexOf (" [[") + 2, 6);
See if this problem,