VB Code:
  1. Private Sub CreateVirtualDir(ByVal WebSite As String, ByVal AppName As String, ByVal Path As String)
  2.  
  3.         Dim IISSchema As New System.DirectoryServices.DirectoryEntry("IIS://" & WebSite & "/Schema/AppIsolated")
  4.         Dim CanCreate As Boolean = Not IISSchema.Properties("Syntax").Value.ToString.ToUpper() = "BOOLEAN"
  5.         IISSchema.Dispose()
  6.  
  7.         If CanCreate Then
  8.             Dim PathCreated As Boolean
  9.  
  10.             Try
  11.                 'make sure folder exists
  12.                 If Not System.IO.Directory.Exists(Path) Then
  13.                     System.IO.Directory.CreateDirectory(Path)
  14.                     PathCreated = True
  15.                 End If
  16.  
  17.                 'create IIS object
  18.                 Dim IISAdmin As New System.DirectoryServices.DirectoryEntry("IIS://" & WebSite & "/W3SVC/1/Root")
  19.  
  20.                 'If the virtual directory already exists then delete it
  21.                 For Each VD As System.DirectoryServices.DirectoryEntry In IISAdmin.Children
  22.                     If VD.Name = AppName Then
  23.                         IISAdmin.Invoke("Delete", New String() {VD.SchemaClassName, AppName})
  24.                         IISAdmin.CommitChanges()
  25.                         Exit For
  26.                     End If
  27.                 Next VD
  28.  
  29.                 'Create and setup new virtual directory
  30.                 Dim VDir As System.DirectoryServices.DirectoryEntry = IISAdmin.Children.Add(AppName, "IIsWebVirtualDir")
  31.  
  32.                 VDir.Properties("Path").Item(0) = Path
  33.                 VDir.Properties("AppFriendlyName").Item(0) = AppName
  34.                 VDir.Properties("EnableDirBrowsing").Item(0) = False
  35.                 VDir.Properties("AccessRead").Item(0) = True
  36.                 VDir.Properties("AccessExecute").Item(0) = True
  37.                 VDir.Properties("AccessWrite").Item(0) = False
  38.                 VDir.Properties("AccessScript").Item(0) = True
  39.                 VDir.Properties("AuthNTLM").Item(0) = True
  40.                 VDir.Properties("EnableDefaultDoc").Item(0) = True
  41.                 VDir.Properties("DefaultDoc").Item(0) = "default.htm,default.aspx,default.asp"
  42.                 VDir.Properties("AspEnableParentPaths").Item(0) = True
  43.                 VDir.CommitChanges()
  44.  
  45.                 'the following are acceptable params
  46.                 'INPROC = 0
  47.                 'OUTPROC = 1
  48.                 'POOLED = 2
  49.                 VDir.Invoke("AppCreate", 1)
  50.  
  51.             Catch Ex As Exception
  52.                 If PathCreated Then
  53.                     System.IO.Directory.Delete(Path)
  54.                 End If
  55.                 Throw Ex
  56.             End Try
  57.         End If
This is used like:
VB Code:
  1. CreateVirtualDir("LocalHost", "Woof", "C:\My Web Apps\Woof")
I completely understand all of the code, except for one line:
VB Code:
  1. Dim CanCreate As Boolean = Not IISSchema.Properties("Syntax").Value.ToString.ToUpper() = "BOOLEAN"
Why? What's it checking? All the code I find on the web has this in, but can't figure out what exactly it's there for

Woka