Search Tools Links Login

Check file existence and attributes

Check the existence of a file and it's attributes (DateCreated, DateLastModified, DateLastAccessed)

Original Author: AepS


Path and file name.


You must have a textbox called txtFileName, two command buttons called cmdFileExist and cmdFileAttributes.


Private Sub cmdFileExist_Click()
Dim FSO, _
  FileName As String, _
  DoExist As Boolean

Set FSO = CreateObject("Scripting.FileSystemObject")
FileName = txtFileName
DoExist = FSO.FileExists(FileName)
MsgBox DoExist, , "Check Existence"
End Sub

Private Sub cmdFileAttributes_Click()
Dim FSO, F
Dim FileName As String

FileName = txtFileName
Set FSO = CreateObject("Scripting.FileSystemObject")
Set F = FSO.GetFile(FileName)
MsgBox "Created : " & F.DateCreated & Chr(13) & _
   "Last Modified : " & F.DateLastModified & Chr(13) & _
   "Last Accessed : " & F.DateLastAccessed, , "Check Attributes"
End Sub

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 95 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.