System.CodeDom.Compiler.TempFileCollection.AddExtension C# (CSharp) Method

AddExtension() public method

public AddExtension ( string fileExtension ) : string
fileExtension string
return string
        public string AddExtension(string fileExtension) => AddExtension(fileExtension, KeepFiles);

Same methods

TempFileCollection::AddExtension ( string fileExtension, bool keepFile ) : string

Usage Example

        private static int InternalExecWaitWithCapture(string cmd, string currentDir, TempFileCollection tempFiles, ref string outputName, ref string errorName)
        {
            if ((cmd == null) || (cmd.Length == 0))
            {
                throw new ExternalException(Locale.GetText("No command provided for execution."));
            }

            if (outputName == null)
            {
                outputName = tempFiles.AddExtension("out");
            }

            if (errorName == null)
            {
                errorName = tempFiles.AddExtension("err");
            }

            int     exit_code = -1;
            Process proc      = new Process();

            proc.StartInfo.FileName               = cmd;
            proc.StartInfo.CreateNoWindow         = true;
            proc.StartInfo.UseShellExecute        = false;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.RedirectStandardError  = true;
            proc.StartInfo.WorkingDirectory       = currentDir;

            try
            {
                proc.Start();

                ProcessResultReader outReader = new ProcessResultReader(proc.StandardOutput, outputName);
                ProcessResultReader errReader = new ProcessResultReader(proc.StandardError, errorName);

                Thread t = new Thread(new ThreadStart(errReader.Read));
                t.Start();

                outReader.Read();
                t.Join();

                proc.WaitForExit();
            }
            finally
            {
                exit_code = proc.ExitCode;
                // the handle is cleared in Close (so no ExitCode)
                proc.Close();
            }
            return(exit_code);
        }
All Usage Examples Of System.CodeDom.Compiler.TempFileCollection::AddExtension