Display selected file information : FileSystemObject « File Path « VBA / Excel / Access / Word






Display selected file information

 
Private Sub cmdFileInfo_Click()
    Dim myFileSystemObject As FileSystemObject, aFile As File

    Set myFileSystemObject = New FileSystemObject
    Set aFile = myFileSystemObject.GetFile("c:\test.txt")
    With aFile
        Debug.Print "Created: " & .DateCreated & vbCrLf
        Debug.Print "Last Accessed: " & .DateLastAccessed & vbCrLf
        Debug.Print "Last Modified: " & .DateLastModified & vbCrLf
        Debug.Print "Size: " & Format(.Size / 1000#, "#0.00") & "KB" & vbCrLf
        Debug.Print "Path: " & .Path & vbCrLf
        Debug.Print "Type: " & .Type
    End With

    Set myFileSystemObject = Nothing
    Set aFile = Nothing
End Sub

 








Related examples in the same category

1.Copying a File
2.Delete file by using FileSystemObject
3.Delete Folder by using FileSystemObject
4.Recursive Search using the FileSystemObject Model
5.Listing files with a For...Each loop