Recipe 20.5. Finding the Path to the Current Framework VersionProblemYou need the path to where the version of the .NET Framework you are running on is located. SolutionUse the GetruntimeDirectoryRuntimeDirectory method (implemented in System.Runtime.InteropServices.RuntimeEnvironment) to return the full path to the folder that the current version of .NET is installed in: public static string GetCurrentFrameworkPath() { return System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(); } DiscussionThere are many reasons why you might want to know the current framework path, including:
The list could go on and on. Since the method to get to the path is pretty far down a namespace chain (System.Runtime.InteropServices.RuntimeEnvironment), it is provided for your programming convenience. See AlsoSee the "Version Class" and "Version.ToString Method" topics in the MSDN documentation. |