FileSystemObject.GetSpecialFolder Method (VB6) |
oFileSysObj.GetSpecialFolder(SpecialFolder)
oFileSysObj
Use: Required
Data Type: FileSystemObject object
Any object variable returning a FileSystemObject object.
SpecialFolder
Use: Required
Data Type: Special folder constant
A value specifying one of three special system folders.
A Folder object
Returns a reference to a Folder object of one of the three special system folders: System, Temporary, and Windows.
SpecialFolder can be one of the following special folder constants:
Constant | Value | Description |
---|---|---|
SystemFolder | 1 | The Windows system folder (/windows/system or /windows/system32) |
TemporaryFolder | 2 | The folder that stores temporary files (../windows/temp) |
WindowsFolder | 0 | The root folder of the Windows system folder tree (/windows or /winnt) |
This method is a great boon for VB programmers who don't want to get involved with the Windows API, which, in the past, is how you had to determine a path to one of the special folders.
You can use the Set statement to assign the Folder object reference to a local object variable. However, if you're interested only in retrieving the path to the special folder, you can do it with a statement like the following:
sPath = oFileSys.GetSpecialFolder(iFolderConst)
or:
sPath = oFileSys.GetSpecialFolder(iFolderConst).Path
The first statement works because the Path property is the Folder object's default property. Since the assignment isn't to an object variable, it's the default property's value, rather than the object reference, that is assigned to sPath.