For example, the ‘C:\WINNT\Microsoft.NET\Framework\v1.0.3705’ dir for the 1.0 framework version.
You can do so using PInvoke to call this native API method:
[C#]
[DllImport('mscoree.dll')]
// Declaration
internal static extern void GetCORSystemDirectory([MarshalAs(UnmanagedType.LPTStr)]System.Text.StringBuilder Buffer,
int BufferLength, ref int Length);
// Gets the path to the Framework directory.
System.Text.StringBuilder sb = new System.Text.StringBuilder(1024);
int size;
// returned value in size can be ignored
GetCORSystemDirectory(sb, sb.Capacity, ref size);
[VB.Net]
’ Declaration
Private Declare Function GetCORSystemDirectory Lib 'mscoree.dll' ( ByVal Buffer As System.Text.StringBuilder, ByVal BufferLength As Integer, ByRef Length As Integer) As Integer
’ Gets the path to the Framework directory.
Dim Path As New System.Text.StringBuilder(1024)
Dim Size As Integer
’ returned value in Size can be ignored
GetCORSystemDirectory(Path, Path.Capacity, Size)
Permalink