using System.Runtime.InteropServices;
var frameworkPath = RuntimeEnvironment.GetRuntimeDirectory();
var cscPath = Path.Combine(frameworkPath, "csc.exe");
Console.WriteLine(frameworkPath); // C:\Windows\Microsoft.NET\Framework\v4.0.30319
Console.WriteLine(cscPath); } // C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe
转载于:https://www.cnblogs.com/talentzemin/p/10944493.html