Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleSee if a file exists and get the time it was last modified
Keywordsfile, exists, time, modified
CategoriesFiles and Directories
 
Use GetAttr to see if the file exists. Use FileDateTime to get the time it was created or last modified.

Thanks to Phil McCarthy

 
Private Sub Command1_Click()
     b$ = Text1.Text

     On Error GoTo filenotfound
     a$ = GetAttr(b$)

     Label1.Caption = "file exists"
     Exit Sub

filenotfound:
     Label1.Caption = "file does not exist"
End Sub

Private Sub Command2_Click()
     b$ = Text1.Text

     On Error GoTo filenotfound
     a$ = FileDateTime(b$)

     Label1.Caption = a$
     Exit Sub

filenotfound:
     Label1.Caption = " Not a valid path or file"
End Sub

Private Sub Form_Load()
    file_name = App.Path
    If Right$(file_name, 1) <> "\" Then file_name = _
        file_name & "\"
    file_name = file_name & "FileTim4.frm"
    Text1.Text = file_name
End Sub
 
Formatted by Neil Crosby
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated