ISSourceFiles.GetItem

Description

This function returns the source file by its index.

Syntax

object.GetItem(aIndex)

Part Attribute Type Description
object Required
The object always implements the ISSourceFiles interface
aIndex In, Required
int
The index of the source file

Return Value

ISSourceFile

Returns the source file by its index.

Example

Display some information about the folder tree, including the files contained.

sub main
  Dim aStore
  Dim aDialogue
  Dim aStream
  Dim aStoredFileName
  Dim aMessage
  
  set aStore = Profile.SourceStore
  EnsureFolder aStore, "Examples"
 
  set aDialogue = Profile.CreateOpenDialog
  aDialogue.Title = "Select File for adding into Source Store"
  aDialogue.Filter = "*.txt||*.rtf||*.doc||*.*||"
  aDialogue.FileName = "*.*"

  if not aDialogue.Execute then exit sub

  set aStream = Profile.MakeStream
  aStream.LoadFromFile(aDialogue.FileName)
  aStoredFileName = "Examples\" & Mid(aDialogue.FileName, InStrRev(aDialogue.FileName, "\") + 1)
 
  aStore.PutFile aStoredFileName, aStream, "The text of the example"
   
  aMessage = GetSubfoldersInfo(aStore.GetFolders(""), 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
       
    
sub EnsureFolder(aStore, aFolderName)
  Dim aFolder

  on error resume next 
  set aFolder = aStore.GetFolder(aFolderName)
  if Err.Number <> 0 Then
    Err.Clear  
    set aFolder = aStore.CreateFolder(aFolderName)
    Profile.MsgBox("The folder '" & aFolder.FullPath & "' was created")
  end if  
end sub
Note:

Version information

Added in v7.8.0