public static List <string> GetFeatureClassNamesFromFileGdb(string pathToOgrInfoExecutable, string gdbFileInfo, double totalMilliseconds, ILogger logger) { var ogrInfoFileInfo = new FileInfo(pathToOgrInfoExecutable); var commandLineArguments = BuildOgrInfoCommandLineArgumentsToListFeatureClasses(gdbFileInfo, null); var processUtilityResult = ProcessUtility.ShellAndWaitImpl(ogrInfoFileInfo.DirectoryName, ogrInfoFileInfo.FullName, commandLineArguments, true, Convert.ToInt32(totalMilliseconds), logger); var featureClassesFromFileGdb = processUtilityResult.StdOut.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToList(); return(featureClassesFromFileGdb.Select(x => x.Split(' ').Skip(1).First()).ToList()); }
private static ProcessUtilityResult ExecuteOgrInfoCommand(string pathToOgrInfoExecutable, List <string> commandLineArguments, double totalMilliseconds, ILogger logger) { var ogrInfoFileInfo = new FileInfo(pathToOgrInfoExecutable); var processUtilityResult = ProcessUtility.ShellAndWaitImpl(ogrInfoFileInfo.DirectoryName, pathToOgrInfoExecutable, commandLineArguments, true, Convert.ToInt32(totalMilliseconds), logger); if (processUtilityResult.ReturnCode != 0) { var argumentsAsString = String.Join(" ", commandLineArguments.Select(ProcessUtility.EncodeArgumentForCommandLine).ToList()); var fullProcessAndArguments = $"{ProcessUtility.EncodeArgumentForCommandLine(ogrInfoFileInfo.FullName)} {argumentsAsString}"; var errorMessage = $"Process \"{ogrInfoFileInfo.Name}\" returned with exit code {processUtilityResult.ReturnCode}, expected exit code 0.\r\n\r\nStdErr and StdOut:\r\n{processUtilityResult.StdOutAndStdErr}\r\n\r\nProcess Command Line:\r\n{fullProcessAndArguments}\r\n\r\nProcess Working Directory: {ogrInfoFileInfo.DirectoryName}"; throw new Ogr2OgrCommandLineException(errorMessage); } return(processUtilityResult); }