Compartir a través de


GetFolder Method

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

object.GetFolder(folderspec) 

Arguments

  • object
    Required. Always the name of a FileSystemObject.

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

Remarks

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

Applies To:

FileSystemObject Object

See Also

Reference

GetAbsolutePathName Method

GetBaseName Method

GetDrive Method

GetDriveName Method

GetExtensionName Method

GetFile Method

GetFileName Method

GetFileVersion Method

GetParentFolderName Method

GetSpecialFolder Method

GetTempName Method

Folder Object

Change History

Date

History

Reason

September 2010

Modified examples.

Customer feedback.