This function returns the source file by its full path.
object.GetFile(aPath)
Part | Attribute | Type | Description |
---|---|---|---|
object |
Required | The object always implements the
ISSourceFolder interface |
|
aPath |
In, Required | string |
The full path of the source file |
Add the selected file into the source folder 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 user folder"
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 = aRootFolder.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 user folder successfully")
else
Profile.MsgBox("The file " & aFile.FullPath & " already exists in the user folder")
end if
end sub