Obtém as propriedades de um arquivo e retorna
um objeto dicionário. Não esquecer de liberar o objeto depois de usá-lo.
Function GetFileProps(ByVal FileName)
On Error Resume Next
If Mid(FileName, 2, 1) <> ":" Then
FileName = Server.MapPath(FileName)
End If
If Err Then Err.Clear
On Error GoTo 0
Dim FSO, F, D
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set F = FSO.GetFile(FileName)
If Err Then
Err.Clear
Set FSO = Nothing
FileStats = Null
On Error GoTo 0
Exit Function
End If
On Error GoTo 0
Set D = Server.CreateObject("Scripting.Dictionary")
D.Add "DateCreated", F.DateCreated
D.Add "DateLastAccessed", F.DateLastAccessed
D.Add "DateLastModified", F.DateLastModified
D.Add "Size", F.Size
D.Add "Name", F.Name
Set F = Nothing
Set FSO = Nothing
Set GetFileProps = D
Set D = Nothing
End Function
Nenhum comentário:
Postar um comentário