Skip to content

Instantly share code, notes, and snippets.

@Rush
Created May 19, 2014 22:57
Show Gist options
  • Save Rush/4b411a0c6434a48e0703 to your computer and use it in GitHub Desktop.
Save Rush/4b411a0c6434a48e0703 to your computer and use it in GitHub Desktop.
C# arguments handling test
using System.Diagnostics;
using System;
class Program
{
public static bool IsRunningOnMono()
{
return Type.GetType ("Mono.Runtime") != null;
}
static void Main(string[] args)
{
if(args.Length > 0) {
System.Console.WriteLine("Environment:" + Environment.CommandLine);
for(int i = 1;i <= args.Length;++i) {
System.Console.WriteLine("Args[" + i + "]:" + args[i-1]);
}
return;
}
var proc = new Process {
StartInfo = new ProcessStartInfo {
FileName = IsRunningOnMono() ?"mono" : "StripArgsTest.exe",
Arguments = (IsRunningOnMono() ?"StripArgsTest.exe ":"") + ": /home/administrator/Projects/UnrealEngine.sbc100/Engine/Binaries/Linux/UE4Editor \"/home/administrator/Documents/Unreal Projects/TappyChicken/TappyChicken.uproject\" -run=Cook -Map=/Game/Maps/TappyChickenMap -TargetPlatform=LinuxNoEditor -buildmachine -Unversioned -fileopenlog -abslog=\"/home/administrator/Library/Logs/Unreal Engine/LocalBuildLogs/Cook.txt\" -stdout -FORCELOGFLUSH -CrashForUAT -unattended -AllowStd",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
proc.Start();
while (!proc.StandardOutput.EndOfStream) {
string line = proc.StandardOutput.ReadLine();
// do something with line
System.Console.WriteLine(line);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment