vb Code:
  1. dim path as string = "c:\windows\system32\drivers\cabs"
  2. dim depth as integer = 3
  3. dim tempArray() as string = path.split("\")
  4.  
  5. dim newPath as string
  6. for x as integer = 1 to depth
  7.     newPath &= tempArray(x-1) & "\"
  8. next

or

io.Directory.GetParent