Path 属性

       

返回一个 String 类型,表示 ScopeFolder 对象的完全路径。只读。

expression.Path

expression   必需。该表达式返回一个 ScopeFolder 对象。

示例

本示例显示“我的电脑”中每个目录的根路径。为了检索该信息,本示例首先获得“我的电脑”根目录下的 ScopeFolder 对象。该 ScopeFolder 的路径将总是 "*"。对于所有 ScopeFolder 对象,根对象包含一个 ScopeFolders 集合。本示例在该 ScopeFolders 集合中循环,并显示其中每个 ScopeFolder 对象的路径。这些 ScopeFolder 对象的路径将为 "A:\"、"C:\" 等等。

Sub DisplayRootScopeFolders()

    'Declare variables that reference a
    'SearchScope and a ScopeFolder object.
    Dim ss As SearchScope
    Dim sf As ScopeFolder

    'Use a With...End With block to reference the
    'FileSearch object.
    With Application.FileSearch

        'Loop through the SearchScopes collection
        'and display all of the root ScopeFolders collections in
        'the My Computer scope.
        For Each ss In .SearchScopes
            Select Case ss.Type
                Case msoSearchInMyComputer

                    'Loop through each ScopeFolder collections in
                    'the ScopeFolders collection of the
                    'SearchScope object and display the path.
                    For Each sf In ss.ScopeFolder.ScopeFolders
                        MsgBox "Path: " & sf.Path
                    Next sf

                Case Else
            End Select
        Next ss
    End With
End Sub