Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 26th, 2012  |  syntax: None  |  size: 0.51 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Executing a unix style piping command?
  2. .binary.exe < input > output
  3.        
  4. ProcessStartInfo info = new ProcessStartInfo("binary.exe");
  5. info.RedirectStandardInput = true;
  6. info.RedirectStandardOutput = true;
  7. Process p = Process.Start(info);
  8.  
  9. string Input;
  10. // Read input file into Input here
  11.  
  12. StreamWriter w = new StreamWriter(p.StandardInput);
  13. w.Write(Input);
  14. w.Dispose();
  15.  
  16. StreamReader r = new StreamReader(p.StandardOutput);
  17. string Output = r.ReadToEnd();
  18. r.Dispose();
  19.  
  20. // Write Output to the output file
  21.  
  22. p.WaitForExit();