I recently had a need to find the path to the .NET Framework binaries. Here's the official way of finding it, using a function exposed from mscoree.dll:
const int MAX_PATH = 256;
public string GetNetFrameworkDirectory() {
StringBuilder buf = new StringBuilder(
MAX_PATH, MAX_PATH);
int cch = MAX_PATH;
int hr = GetCORSystemDirectory(
buf, MAX_PATH, ref cch);
if (hr < 0) Marshal.ThrowExceptionForHR(hr);
return buf.ToString();
}
[DllImport("mscoree.dll",
CharSet=CharSet.Unicode,
ExactSpelling=true)]
public static extern int GetCORSystemDirectory(
StringBuilder buf,
int cchBuf,
ref int cchRequired);
This returned the following string on my 1.1 box:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\
Posted
Oct 18 2005, 02:33 PM
by
keith-brown