/// <summary>
        /// Creates the process.
        /// </summary>
        /// <param name="fileSystem">The file system.</param>
        /// <returns>
        /// The new <see cref="Process"/>.
        /// </returns>
        public Process CreateProcess(IFileSystem fileSystem)
        {
            var executableInWorkingDirectory = Path.Combine(WorkingDirectory ?? string.Empty, FileName);

            if (fileSystem.CheckIfFileExists(executableInWorkingDirectory))
            {
                startInfo.FileName = executableInWorkingDirectory;
            }

            // if WorkingDirectory is filled in, check that it exists
            if (!string.IsNullOrEmpty(WorkingDirectory) &&
                !fileSystem.CheckIfDirectoryExists(WorkingDirectory))
            {
                throw new DirectoryNotFoundException("Directory does not exist: " + WorkingDirectory);
            }

            logger.Debug("Creating process for '{0}'", this.FileName);
            var process = new Process {
                StartInfo = startInfo
            };

            return(process);
        }
Example #2
0
        /// <summary>
        /// Creates the process.
        /// </summary>
        /// <param name="fileSystem">The file system.</param>
        /// <returns>
        /// The new <see cref="Process"/>.
        /// </returns>
        public Process CreateProcess(IFileSystem fileSystem)
        {
            var executableInWorkingDirectory = Path.Combine(WorkingDirectory ?? string.Empty, FileName);
            if (fileSystem.CheckIfFileExists(executableInWorkingDirectory))
            {
                startInfo.FileName = executableInWorkingDirectory;
            }

            // if WorkingDirectory is filled in, check that it exists
            if (!string.IsNullOrEmpty(WorkingDirectory) &&
                !fileSystem.CheckIfDirectoryExists(WorkingDirectory))
            {
                throw new DirectoryNotFoundException("Directory does not exist: " + WorkingDirectory);
            }

            logger.Debug("Creating process for '{0}'", this.FileName);
            var process = new Process { StartInfo = startInfo };
            return process;
        }