Advertisement
4_2005-2006 Files/ File Controls/ Input/ Output #153641

CreateDirectoryStruct

Creates all non-existing folders in a path. Local or network UNC path.

AI

KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Quellcode
original-source
Private Sub CreateDirectoryStruct(CreateThisPath As String)
  'do initial check
  Dim ret As Boolean, temp$, ComputerName As String, IntoItCount As Integer, x%, WakeString As String
  Dim MadeIt As Integer
  If Dir$(CreateThisPath, vbDirectory) <> "" Then Exit Sub
  'is this a network path?
  If Left$(CreateThisPath, 2) = "\\" Then ' this is a UNC NetworkPath
    'must extract the machine name first, then get to the first folder
    IntoItCount = 3
    ComputerName = Mid$(CreateThisPath, IntoItCount, InStr(IntoItCount, CreateThisPath, "\") - IntoItCount)
    IntoItCount = IntoItCount + Len(ComputerName) + 1
    IntoItCount = InStr(IntoItCount, CreateThisPath, "\") + 1
    'temp = Mid$(CreateThisPath, IntoItCount, x)
  Else  ' this is a regular path
    IntoItCount = 4
  End If
  
  WakeString = Left$(CreateThisPath, IntoItCount - 1)
  'start a loop through the CreateThisPath string
  Do
    x = InStr(IntoItCount, CreateThisPath, "\")
    If x <> 0 Then
      x = x - IntoItCount
      temp = Mid$(CreateThisPath, IntoItCount, x)
    Else
      temp = Mid$(CreateThisPath, IntoItCount)
    End If
    IntoItCount = IntoItCount + Len(temp) + 1
    temp = WakeString + temp
    
    'Create a directory if it doesn't already exist
    ret = (Dir$(temp, vbDirectory) <> "")
    If Not ret Then
      'ret& = CreateDirectory(temp, Security)
      MkDir temp
    End If
    
    IntoItCount = IntoItCount  'track where we are in the string
    WakeString = Left$(CreateThisPath, IntoItCount - 1)
  Loop While WakeString <> CreateThisPath
  
End Sub
Originalkommentare (3)
Wiederhergestellt von der Wayback Machine