What should you do?

You are required to launch the App.exe process, and specify sample.txt as the input file.
App.exe will then use the contents of sample.txt to establish the environment’s current settings.
You need to ensure that the code you use meets these requirements.
What should you do?

You are required to launch the App.exe process, and specify sample.txt as the input file.
App.exe will then use the contents of sample.txt to establish the environment’s current settings.
You need to ensure that the code you use meets these requirements.
What should you do?

A.
Use the following code:
Process myProcess = new Process ();
myProcess.StartInfo = new ProcessStartInfo(“App.exe sample.txt”);
myProcess.Start ();

B.
Use the following code:
Process myProcess = new Process ();
myProcess.StartInfo = new ProcessStartInfo(“App.exe”);
myProcess.ProcessStartArgs (“sample.txt”);
myProcess.Start();

C.
Use the following code:
Process myProcess = new Process ();
myProcess.StartInfo = new ProcessStartInfo(“App.exe”);
myProcess.Start(“sample.txt”);

D.
Use the following code:
Process myProcess = new Process ();
myProcess.StartInfo = new ProcessStartInfo(“App.exe”);
myProcess.StartInfo.FileName = “sample.txt”;
myProcess.Start();

Explanation:
This code creates a new Process object, sets the application to run using the StartInfo property,
and uses the FileName property to specify the file to use as input. The StartInfo property of a Process object stores startup information for the process. This includes the application to run and any command-line arguments to be used by the application.
The FileName property must be set, and can be set by either explicitly setting the FileName property or
by passing the name of the file to the ProcessStartInfo constructor. The Start method launches the application process with the values specified in the StartInfo property.
In this scenario, the code declares a new Process object named myProcess and then sets the StartInfo property of this process.
The code passes the constructor of the ProcessStartInfo a single argument representing the name of the application, App.exe.
Next, the FileName property is explicitly set with an assignment statement to the value of “sample.txt”.
Then, the code call the Start method to launch the application using the values specified in the customized startup settings.
Falsch:
A: You should not use the code that passes a single string containing the application and input file to the ProcessStartInfo constructor.
B: You should not use the code that invokes the ProcessStartArgs method because no such method exists in the Process class.
C: You should not use the code that invokes the Start method of the Process object specifying the input file because no such method signature exists.



Leave a Reply 1

Your email address will not be published. Required fields are marked *


networkmanagers

networkmanagers

Correct answer is D