I am having an exe file that takes path of an excel file as an input. It generates several splitted excel files as an output. but the output directory needs to be specified where the spliited output files need to be stored. Can any one help me with this.
1 Answer
You can use the Process class to achieve this:
using (p = new System.Diagnostics.Process())
{
p.StartInfo.FileName = "PathTo.exe";
// Provide command line argument
p.StartInfo.Arguments = "arg1 arg2 arg3 \"Arg with whitespace\"";
// You can also try to set the working directory when you run the process
p.UseShellExecute = false;
p.WorkingDirectory = @"C:\OutputDirectory";
p.Start();
// In case you want to wait for the process to exit
p.WaitForExit();
}
3 Comments
Ananya Malik
hi, thanks for the answer. Bt i already am getting a window of exe file after passing the args. i just dont knw how to redirect the output of exe to a new directory.
Markus
@AnanyaMalik: that depends on the exe file you are calling. Maybe you can change it in the arguments, maybe you can solve it by setting the working directory. I've updated the sample.
Ananya Malik
Thnx alot. I got it working .. :)