Export (0) Print
Expand All

GetFolder Method

Updated: September 2010

Returns a Folder object corresponding to the folder in a specified path.

object.GetFolder(folderspec) 

object

Required. Always the name of a FileSystemObject.

folderspec

Required. The folderspec is the path (absolute or relative) to a specific folder.

An error occurs if the specified folder does not exist.

The following example illustrates the use of the GetFolder method.

function ShowFolderList(path) {
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var folder = fso.GetFolder(path);
    var subFlds = new Enumerator(folder.SubFolders);

    var s = "";
    for (; !subFlds.atEnd(); subFlds.moveNext()) {
        s += subFlds.item()
        s += "<br />";
    }
    return (s);
}
Function ShowFolderList(path)
    Dim fso, folder, subFlds, fld, s

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set folder = fso.GetFolder(path)
    Set subFlds = folder.SubFolders

    s = ""
    For Each fld in subFlds
        s = s & fld.name
        s = s & "<br />"
    Next

    ShowFolderList = s
End Function

Date

History

Reason

September 2010

Modified examples.

Customer feedback.

Community Additions

Show:
© 2014 Microsoft