ISSourceStore.PutFile

Description

This function puts the file with the specified path into the source store.

Syntax

object.PutFile(aPath, aFileData, aComment)

Part Attribute Type Description
object Required
The object always implements the ISSourceStore interface
aPath In, Required
string
The full path of the file in the source store
aFileData In, Required
The content of the file
aComment In, Required
string
The comment to the file

Return Value

ISSourceFile

Returns the file with the specified path being put into the source store.

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:

See also

Version information

Added in v7.8.0