FileSearch 属性

       

返回 FileSearch 对象。

注释

FileSearch 对象不接受统一资源定位符 (URL) 作为文件名或文件夹名称的值。

示例

本示例搜索 Adventure Works 站点及其子目录,并返回在站点中找到的 Index.htm 文件的数目。

注意  若要运行本示例,必须有名为“C:\My Documents\My Webs\Adventure Works”(对于在 Microsoft Windows 上运行的服务器)或“C:\WINNT\Profiles\logon alias\Personal\My Webs\Adventure Works”(对于在 Windows NT 运行的服务器)的站点。您也可以将 LookIn 的值更改为您当前可用的站点。您还必须设置对 Microsoft Office 对象库的引用。

Private Sub WebFileSearch()
    Dim myFileSearch As FileSearch
    Dim myFileCount As Integer

    Set myFileSearch = Application.FileSearch

    With myFileSearch
            .FileName = "index.htm"
            .LookIn = "C:\My Webs\Adventure Works"
            .SearchSubFolders = True
            .Execute
            myFileCount = .FoundFiles.Count
    End With
End Sub