by AepS (2 Submissions)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating:
(5 Votes)
Check the existence of a file and it's attributes (DateCreated, DateLastModified, DateLastAccessed)
Inputs
Path and file name.
Assumes
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