ISSourceStore.GetFile

Description

This function returns the source file by its full path.

Syntax

object.GetFile(aPath)

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

Return Value

ISSourceFile

Returns the source file by its full path.

Example

Add the selected file into the source store if it doesn't exist.

sub main                           
  Dim aStore
  Dim aRootFolder, aRootFolderName 
  Dim aDialogue 
  Dim aStream
  Dim aFile
  Dim aStoredFileName
  
  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 
 
  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 = aRootFolder.FullPath & "\" & Mid(aDialogue.FileName, InStrRev(aDialogue.FileName, "\") + 1)
 
  set aFile = aStore.GetFile(aStoredFileName)
  if Err.Number <> 0 Then
    Err.Clear
    set aFile = aStore.PutFile(aStoredFileName, aStream, "The text of the example")
    Profile.MsgBox("The file " & aFile.FullPath & " is added to the source store successfully")    
  else    
    Profile.MsgBox("The file " & aFile.FullPath & " already exists in the source store")
  end if
end sub    
Note:

Version information

Added in v7.8.0