What is the easiest way to get the directory of the most current .Net Framework installation in C# code and also in a batch file.
I need to set some code access security settings using the caspol.exe which is in the framework directory but it is different on different machines. For example on a windows 2000 machine it is in c:\winnt\microsoft.net\framework\<framework version>.. and on an XP machine it is in c:\windows\microsoft.net\framework\<framework version>..
I can get around the windows vs winnt by using the %SystemRoot% environment variable but I don't know of any easy way to determine the most current version of the framework in a batch file at least.
Any assistance would be helpful.
Thanks,

Get lastest version .Net Framework Directory
ThisObject
EmilF
System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory();
Thanks to Jamie Cansdale, for pointing this out to me.