Advertisement
Suchiman

Untitled

Sep 2nd, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1. public static ProcessStartInfo ParseCommandLine(string command)
  2. {
  3.     string[] segments = command.Split(new[] { '"' }, StringSplitOptions.RemoveEmptyEntries);
  4.     string filename = "";
  5.     string args = "";
  6.     if (segments.Length == 1)
  7.     {
  8.         filename = segments[0];
  9.     }
  10.     else if (segments.Length == 2)
  11.     {
  12.         filename = segments[0];
  13.         args = segments[1];
  14.     }
  15.     return new ProcessStartInfo(filename.Trim(), args.Trim());
  16. }
  17.  
  18. var test = ParseCommandLine("C:/my/long/path/executable.exe \"omg\"");
  19. //test.fileName == "C:/my/long/path/executable.exe"
  20. //test.Arguments == "omg"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement