WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

IMAPI

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

IMAPI Create Subdirectory and Add File

 Keywords:  IMAPI IMAP2 Burn IMAPI2FS.MsftFileSystemImage.1 Add File AddDirectory AddTree get_Item get_Root Method Directory Subdirectory

Each and every directory object is seperate. You cannot add a file to a directory object if the file would end up in a subdirectory. Or, put in reverse, you can only add a file to the current directory.

To add files to a subdirectory, you not only have to create the subdirectory, but you also have to get the subdirectory object in order to add a file to it.

; NOTE:
; Each and every directory object is seperate.  You cannot add a file to a directory object if the file
; would end up in a subdirectory.  Or, put in reverse, you can only add a file to the current directory.
;
; To add files to a subdirectory, you not only have to create the subdirectory, but you also have to get
; the subdirectory object in order to add  a file to it.

oFSI = CreateObject("IMAPI2FS.MsftFileSystemImage.1")

dir1 = "sample_dir1"
dir2 = "sample_dir2"
file = "samplefile.txt"

; Get the root directory item.
oRoot = oFSI.get_Root()

; Add First Directory
oRoot.AddDirectory( dir1 )

; Get Object Handle of First Directory
oDir1 = oRoot.get_Item( dir1 )

; Add Subdirectory
oDir1.AddDirectory( dir2 )

; Get Object Handle of Subdirectory
oDir2 = oDir1.get_Item( dir2 )

; Add file to Subdirectoy
oDir2.AddTree( file, @TRUE )

oDir2 = 0
oDir1 = 0
oRoot = 0
Exit

Article ID:   W18078
Filename:   IMAPI Create Subdirectory.txt
File Created: 2011:04:19:11:18:16
Last Updated: 2011:04:19:11:18:16