tags:

views:

349

answers:

1

I need a method to know iis current wwwroot in VB.Net.

I need to get this information outside a web project (otherwise the problem would have a simple solution). I think I need to read this information from the registry, but I have no idea where to start looking.

Thank you

A: 

Well, you can certainly get the IIS "root" folder from the registry.

It can be found in the following location:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\PathWWWRoot\

and some very simple VB.NET code to retrieve this value could be something as simple as:

Imports Microsoft.Win32

Module Module1

    Sub Main()
        Dim rootFolder As String = Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\", "PathWWWRoot", "").ToString()
        Console.WriteLine("IIS Root Folder: " & rootFolder)
        Console.ReadLine()
    End Sub

End Module

(The above code sample is run from a console application and contains no error checking etc.)

CraigTP
Thanks, it works fine
Antonio
Excellent work!
Quandary