Skip to content

Instantly share code, notes, and snippets.

@DominicFinn
Created August 7, 2012 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DominicFinn/3283763 to your computer and use it in GitHub Desktop.
Save DominicFinn/3283763 to your computer and use it in GitHub Desktop.
Doing something with an external exe
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
var folder = new DirectoryInfo(args[0].ToString());
Parallel.ForEach(folder.EnumerateFiles(), DoSomething);
}
static void DoSomething(FileInfo file)
{
var proc = new Process {StartInfo =
{
FileName = "something.exe",
Arguments = file.Name.ToString()
}};
proc.Start();
proc.WaitForExit();
proc.ExitCode;
proc.Close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment