using System.Runtime.InteropServices;
var frameworkPath = RuntimeEnvironment.GetRuntimeDirectory();
var cscPath = Path.Combine(frameworkPath, "csc.exe");
Console.WriteLine(frameworkPath); // C:WindowsMicrosoft.NETFrameworkv4.0.30319
Console.WriteLine(cscPath); } // C:WindowsMicrosoft.NETFrameworkv4.0.30319csc.exe