Reputation: 11745
I have an Console application which runs as background process and there is an exe which needs to be called.This exe takes complete fill path as parameter and then encrypts that file. I did this way :
Process.Start( "myapp.exe" );
But what i want is this :
Process.Start( "myapp.exe file1.txt" ); // File1 is parameter of that exe
But this is not working. Looking for help & advice.
Thanks :)
Upvotes: 2
Views: 4091
Reputation: 769
Process.Start(<the nameof the process
>,<the parameters
>)
In your case
Process.Start("myapp.exe","file1.txt")
Upvotes: 0
Reputation: 7827
Process.Start("[drive]:\[directory]\myapp.exe", "file1.txt");
Substitute the actual drive and directory where indicated
Upvotes: 1
Reputation: 9799
Use something like this:
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "myApp.exe";
p.StartInfo.Arguments = "file1.txt";
p.Start();
Upvotes: 1
Reputation: 29640
You want to use the ProcessStartInfo
class.
See http://msdn.microsoft.com/en-us/library/system.diagnostics.process.startinfo.aspx and http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.aspx for an example on how to use this.
Use the Arguments
property to set your arguments.
Upvotes: 2