Passing values for method

Posted by Kasun on Stack Overflow See other posts from Stack Overflow or by Kasun
Published on 2010-06-15T06:00:15Z Indexed on 2010/06/15 6:52 UTC
Read the original article Hit count: 175

Filed under:

I beginner for programming. So can you please show me how to pass values for your compile() method.

class CL
{

    private const string clexe = @"cl.exe";
    private const string exe = "Test.exe", file = "test.cpp";
    private string args;
    public CL(String[] args)
    {
        this.args = String.Join(" ", args);
        this.args += (args.Length > 0 ? " " : "") + "/Fe" + exe + " " + file;
    }   

    public Boolean Compile(String content, ref string errors)
    {
        //remove any old copies
        if (File.Exists(exe))
            File.Delete(exe);
        if (File.Exists(file))
            File.Delete(file);

        File.WriteAllText(file, content);

        Process proc = new Process();
        proc.StartInfo.UseShellExecute = false;
        proc.StartInfo.RedirectStandardOutput = true;
        proc.StartInfo.RedirectStandardError = true;
        proc.StartInfo.FileName = clexe;
        proc.StartInfo.Arguments = this.args;
        proc.StartInfo.CreateNoWindow = true;

        proc.Start();
        //errors += proc.StandardError.ReadToEnd();
        errors += proc.StandardOutput.ReadToEnd();

        proc.WaitForExit();

        bool success = File.Exists(exe);

        return success;
    }
}

© Stack Overflow or respective owner

Related posts about c#