private static string GetCustomDataDirectory(string cmdline) { string argName = "-datadir="; IEnumerable <string> args; try { args = ProcessUtils.CommandLineToArgs(cmdline); } catch { return(null); } foreach (var arg in args) { if (!string.IsNullOrWhiteSpace(arg) && arg.ToLower().StartsWith(argName) && arg.Length > argName.Length) { return(arg.Substring(argName.Length)); } } return(null); }