Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a virtual directory

Status
Not open for further replies.

MartDawg

Programmer
Jan 14, 2004
33
US
Anybody know how to create a virtual directory in Visual Basic?
 
A quick google returned the following result.


Here is a stripped down version of the code that works.

Code:
Dim sComputer As String
    Dim sPhyDir As String
    Dim sVirDir As String
    Dim strLogDesc As String
    Dim vRoot As Object
    Dim vdir As Object
    
    sComputer = "localhost"
    sPhyDir = "c:\testfax"
    sVirDir = "TestFax"
    
    Set vRoot = GetObject("IIS://" & strcomputer & "LOCALHOST/W3SVC/1/ROOT")
    Set vdir = vRoot.Create("IIsWebVirtualdir", sVirDir)
    
    vdir.AccessRead = True
    vdir.AccessWrite = True
    vdir.AccessExecute = True
    vdir.Path = sPhyDir
    vdir.SetInfo
    Set vdir = Nothing
    Set vRoot = Nothing
 
Ahh, I noticed a glaring typeo in my code. I changed it at the last minute.

Set vRoot = GetObject("IIS://" & strcomputer & "LOCALHOST/W3SVC/1/ROOT")


Should be

Code:
Set vRoot = GetObject("IIS://" & strcomputer & "/W3SVC/1/ROOT")

Without the LOCALHOST part, cause you're already specifying it with strComputer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top