Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting File Date,Time and Size 3

Status
Not open for further replies.

CaKiwi

Programmer
Apr 8, 2001
1,294
US
Hi,

Can anyone tell me how to find the creation date, creation time and size of a file in VB?

Thanks CaKiwi
 
FileDateTime returns the date and time the file was last modified but not created. I am not sure if there is a VB command to tell you creation time/date. Maybe an API.

FileLen returns the file size in bytes.

Hope this helps.

Matt
 
Thanks for the rapid response. Modified time will be good enough for my purpose. CaKiwi
 
in case anybody's interested...

Code:
Option Explicit

Private Sub Command1_Click()
  Dim oFSO As Object
  Dim oFile As Object
  Dim sFile As String
  
  sFile = "C:\My Documents\OT.xls"
  
  Set oFSO = CreateObject("Scripting.FileSystemObject")
  Set oFile = oFSO.GetFile(sFile)
  With oFile
    Debug.Print "DateCreated", .DateCreated
    Debug.Print "DateLastModified", .DateLastModified
    Debug.Print "Size", .Size
    Debug.Print "ShortPath", .ShortPath
  End With
  
  Set oFile = Nothing
  Set oFSO = Nothing
End Sub

gives
[tt]
DateCreated 7/9/01 5:35:35 PM
DateLastModified 1/12/02 1:19:18 PM
Size 152064
ShortPath C:\MYDOCU~1\OT.XLS[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top