FileSystemObject.GetSpecialFolder Method (VB6) |
Syntax
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.
Return Value
A Folder object
Description
Returns a reference to a Folder object of one of the three special system folders: System, Temporary, and Windows.
Rules at a Glance
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) |
Programming Tips and Gotchas
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 ...
Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.