Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
In the Windows Shell, folders are Component Object Model (COM) objects. This means that, before you can access the properties of an individual folder, you must create an object reference to that folder, a process commonly referred to as binding. You can bind to a folder by creating an instance of the FileSystemObject and then using the GetFolder method to connect to the folder.
When using the GetFolder method, you must:
objFSO.GetFolder(
"C:\FSO
",
"C:\Scripts
")
If you need to work with multiple folders, you either need to use WMI (which can return a collection of folders) or create a separate object reference for each folder.
For example, the script in Listing 4.5 binds to the folder C:\FSO.
Listing 4.5 Binding to a Folder
|
|
Although wildcard characters are not allowed, you can use the dot (.) to bind to the current folder, dot-dot (..) to bind to the parent folder of the current folder, and the backslash (\) to bind to the root folder. For example, the following code statement binds to the current folder:
Set objFolder = objFSO.GetFolder(
".
")
Send us your feedback | « Previous | Next » |