HI all,

Can anyone tell me the method of detecting the presence of dotnet framework 2.0

Thanks in advance .

Manju Saharan

Hi there, I found this article which will answer your question.


The upshot is that the easiest way to determine which versions of the .NET Framework you have installed on a computer is to locate the \Microsoft.NET\Framework folder in the drive you installed it on. Please mark your thread as solved if you are happy with this answer.
Hope this helps!

This following code to detect .net version, Hope it help u :

using System.IO;

public string GetNetVersion()
    string functionReturnValue = null;
    //   PURPORSE : Get the highest .NET framework version from the directy name
    //              support.microsoft.com/kb/318785/en-us
    //              Assumes microsoft will continue naming convention
    //              %systemroot%\Microsoft.NET\Framework\vN.N.NXXXX
    //   SECURITY : Authenticated Users (Win2000)
    //    RETURNS : Numeric portion of direcory name as a [String]
    string SystemDirectory = Environment.GetEnvironmentVariable("SystemRoot");
    string strWorkingDir = SystemDirectory + "\\Microsoft.NET\\Framework\\";
    Directory NetFramework;
    string[] strProcessDirs;
    string strVersion;
    double intNetMajor;
    double intVal;
    int i;
    int j = Strings.Len(strWorkingDir) + 1;
    if (System.IO.Directory.Exists(strWorkingDir) == true) {
         // ERROR: Not supported in C#: ReDimStatement

        // get the subdirectories that match the filter
        NetFramework.GetDirectories(strWorkingDir, "v?.*").CopyTo(strProcessDirs, (0));
        for (i = 0; i <= strProcessDirs.GetUpperBound(0); i++) {
            if (strProcessDirs(i) != "") {
                // strip the path and the 'v' from the directory name
                strVersion = Microsoft.VisualBasic.Right(strProcessDirs(i), Strings.Len(strProcessDirs(i)) - j);
                // get the left three chars as a decimal
                intVal = (double)Microsoft.VisualBasic.Left(strVersion, 3);
                //resolve the highest version number
                if (intVal > intNetMajor) {
                    intNetMajor = intVal;
                    // return the higer version as string
                    functionReturnValue = strVersion;
    return functionReturnValue;
private void Form2_Load(object sender, System.EventArgs e)
    Label1.Text = GetNetVersion();

Oh I didn't realise the OP meant in code! lol, oops! my mistake!

Oh I didn't realise the OP meant in code! lol, oops! my mistake!

Actually he want code to detect .net framework present or not but i didn't know it. but it your link posted (msdn) has a link to some site that it give a code to detect .net framework but not in C#

Oh I see, Ok Jx_man I see what you mean there :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.