ISSourceFolder.GetFolder

Description

This function returns the source folder by its full path.

Syntax

object.GetFolder(aPath)

Part Attribute Type Description
object Required
The object always implements the ISSourceFolder interface
aPath In, Required
string
The full path of the source folder

Return Value

ISSourceFolder

Returns the source folder by its full path.

Example

Create a new subfolder inside the source folder and display some information about the source folder tree.

sub main
  Dim aStore
  Dim aRootFolder
  Dim aRootFolderName
  Dim aNewFolder
  Dim aNewFolderName
  Dim aNewFolderFullPath              
  Dim aCreationMessage
  Dim aMessage
             
  aRootFolderName = Profile.CurrentUserCode 

  set aStore = Profile.SourceStore  
  
  on error resume next 
  set aRootFolder = aStore.GetFolder(aRootFolderName)
  if Err.Number <> 0 Then
    Err.Clear  
    set aRootFolder = aStore.CreateFolder(aRootFolderName)
  end if    
   
  aNewFolderName = InputBox("Folder Creation", "Enter Folder Name")
  
  aNewFolderFullPath = aRootFolder.FullPath & "/" & aNewFolderName 
  set aNewFolder = aRootFolder.GetFolder(aNewFolderFullPath) 
  if Err.Number <> 0 Then
    Err.Clear  
    set aNewFolder = aStore.CreateFolder(aNewFolderFullPath) 
    aCreationMessage = "New subfolder with path " & aNewFolder.FullPath & " is created successfully"
  else
    aCreationMessage = "Subfolder with path " & aNewFolder.FullPath & " already exists"        
  end if    

  aMessage = aCreationMessage & vbNewLine & vbNewLine &_
    GetSubfoldersInfo(aRootFolder.GetFolders(aRootFolder.FullPath), 0)
  
  Profile.MsgBox(aMessage)
end sub

function GetSubfoldersInfo(aFolders, aLevel)
  Dim i, j
  Dim aFolder, aSubFolders
  Dim aFiles, aFile
  Dim aInfo
            
  for i = 0 to aFolders.Count - 1
    set aFolder = aFolders.GetItem(i)
    set aFiles = aFolder.GetFiles(aFolder.FullPath)
    
    aInfo = aInfo & vbNewLine & Space(aLevel * 4) & aFolder.FullPath &_
      " (Files: " & aFiles.Count & ")"
    for j = 0 to aFiles.Count - 1 
      set aFile = aFiles.GetItem(j)
      aInfo = aInfo & vbNewLine & Space(aLevel * 4) & "-" & aFile.FileName      
    next 'j
      
    set aSubFolders = aFolder.GetFolders(aFolder.FullPath) 
    aInfo = aInfo & GetSubfoldersInfo(aSubFolders, aLevel + 1)
  next 'i
  
  GetSubfoldersInfo = aInfo
end function                  
Note:

Version information

Added in v7.8.0