Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- public class simpletest
- {
- static public void Main ()
- {
- // start with working situation
- var psi = new ProcessStartInfo() {
- FileName = "/usr/bin/7z",
- Arguments = "a bob.7z simpletest.cs",
- UseShellExecute = false
- };
- Console.WriteLine(">>> I expect this to work <<<");
- var proc = new Process() { StartInfo = psi, };
- proc.Start();
- proc.WaitForExit();
- Console.WriteLine(">>> I expect this to work <<<");
- psi.UseShellExecute = true;
- proc = new Process() { StartInfo = psi, };
- proc.Start();
- proc.WaitForExit();
- Console.WriteLine(">>> I expect this to fail with the missing process error <<<");
- psi.FileName = "/usr/bin/7zz";
- psi.UseShellExecute = false;
- proc = new Process() { StartInfo = psi, };
- try {
- proc.Start();
- proc.WaitForExit();
- } catch (System.ComponentModel.Win32Exception ex) {
- Console.WriteLine(ex);
- }
- Console.WriteLine(">>> I expect this to fail with the xdg-open error <<<");
- psi.UseShellExecute = true;
- proc = new Process() { StartInfo = psi, };
- proc.Start();
- proc.WaitForExit();
- }
- }
Add Comment
Please, Sign In to add comment