Created
August 7, 2012 09:24
-
-
Save DominicFinn/3283763 to your computer and use it in GitHub Desktop.
Doing something with an external exe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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