Guest User

Untitled

a guest
Apr 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3.  
  4. public class simpletest
  5. {
  6. static public void Main ()
  7. {
  8. // start with working situation
  9. var psi = new ProcessStartInfo() {
  10. FileName = "/usr/bin/7z",
  11. Arguments = "a bob.7z simpletest.cs",
  12. UseShellExecute = false
  13. };
  14. Console.WriteLine(">>> I expect this to work <<<");
  15. var proc = new Process() { StartInfo = psi, };
  16. proc.Start();
  17. proc.WaitForExit();
  18.  
  19. Console.WriteLine(">>> I expect this to work <<<");
  20. psi.UseShellExecute = true;
  21. proc = new Process() { StartInfo = psi, };
  22. proc.Start();
  23. proc.WaitForExit();
  24.  
  25. Console.WriteLine(">>> I expect this to fail with the missing process error <<<");
  26. psi.FileName = "/usr/bin/7zz";
  27. psi.UseShellExecute = false;
  28. proc = new Process() { StartInfo = psi, };
  29. try {
  30. proc.Start();
  31. proc.WaitForExit();
  32. } catch (System.ComponentModel.Win32Exception ex) {
  33. Console.WriteLine(ex);
  34. }
  35.  
  36. Console.WriteLine(">>> I expect this to fail with the xdg-open error <<<");
  37. psi.UseShellExecute = true;
  38. proc = new Process() { StartInfo = psi, };
  39. proc.Start();
  40. proc.WaitForExit();
  41. }
  42. }
Add Comment
Please, Sign In to add comment