" GetDetailsOf"返回属性名称的方法,而不是值

时间:2018-04-23 00:16:56

标签: vbscript

我正在努力找到"作者" "最后修改者"目录中每个文件的详细信息,我使用VBScript循环,因为我认为这比使用VBA更快。我遇到的问题是我的代码只返回"所有者"和"作者"而不是实际值。在VBA中获取这些值时我没有遇到任何问题,但它的速度非常缓慢。

到目前为止,我有以下代码:

Set objDlg = WScript.CreateObject("Shell.Application")
'''startFolder = objStartFolder.ParentFolder.ParseName(objStartFolder.Title).Path
startFolder = oShell.NameSpace("C:\Users\x4ujoh\Desktop\")

'Run the function 
ReportFiles startFolder

Function ReportFiles(folderName)
    Dim objFolder, objFile, fileCollection, folderCollection, subFolder

    Set objFolder = objFSO.GetFolder(folderName)
    Set fileCollection = objFolder.Files

    For Each objFile In fileCollection
        strFilePath = Chr(34) & objFile.Path & Chr(34) 
        strFileName = Chr(34) & objFile.Name & Chr(34)
        strFileSize = objFile.Size / 1024
        strFileType = Chr(34) & objFile.Type & Chr(34)
        strFileDateCreated = objFile.DateCreated
        strFileDateLastAccessed = objFile.DateLastAccessed
        strFileDateLastModified = objFile.DateLastModified

        strFilePathRep = Replace(objFile.Path, objFile.Name, "")

        strFileAuthor = Chr(34) & objDlg.NameSpace(strFilePathRep).GetDetailsOf(objFile.Name, 10) & Chr(34)
        strFileLastModifiedBy = Chr(34) & objDlg.NameSpace(strFilePathRep).GetDetailsOf(objFile.Name, 20) & Chr(34)

        objReportFile.Write(strFilePath & "," & strFileName & "," & strFileSize & "," & strFileType & "," & strFileDateCreated & "," & strFileDateLastAccessed & "," & strFileDateLastModified & "," & strFileAuthor & "," & strFileLastModifiedBy & Chr(13) & Chr(10))
    Next

    'Loop for each sub folder 
    Set folderCollection = objFolder.SubFolders

    For Each subFolder In folderCollection
       ReportFiles subFolder.Path
    Next
End Function

enter image description here

1 个答案:

答案 0 :(得分:0)

您必须使用GetDetailsOf(objFile, ...)而不是GetDetailsOf(objFile.Name, ...)