2013-05-15 41 views
0

我試圖在VBScript中使用這個屬性:dateCreated會,如下所述: http://msdn.microsoft.com/en-us/library/ke6a7czx%28v=vs.84%29.aspx的VBScript - 對象不支持此屬性或方法:dateCreated會

但我得到以下錯誤: Microsoft VBScript運行時錯誤:

Object doesn't support this property or method: 'objFSO.DateCreated'

我在互聯網上找不到任何信息,有人可以幫忙嗎?

這一塊我的代碼:

Function showFile(str) 
    Set objFSO = CreateObject("Scripting.FileSystemObject") 
    Set objReadFile = objFSO.OpenTextFile(str , 1, False) 

    contents = objReadFile.ReadAll 
    objReadFile.close 

    strCreated= objFSO.DateCreated 

回答

4

你沒有得到你的代碼FileFolder對象,但你要調用該方法的FileSystemObject(ActiveX組件本身)。

你需要獲得一個File對象爲特定的文件名,如你在你的問題的鏈接頁面上的MSDN示例代碼描述上調用DateCreated:他們在FileSystemObject調用GetFile

Dim fso, f 
Set fso = CreateObject("Scripting.FileSystemObject") 
Set f = fso.GetFile(filespec) 
ShowFileInfo = "Created: " & f.DateCreated 

以實際得到File對象。

+0

謝謝Ansgar - 我從MSDN頁面複製了OP鏈接到他的問題中的代碼。很顯然,我在錯誤的選項卡上... –

相關問題