VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Check file existence and attributes

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.

Rate Check file existence and attributes

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

Download this snippet    Add to My Saved Code

Check file existence and attributes Comments

No comments have been posted about Check file existence and attributes. Why not be the first to post a comment about Check file existence and attributes.

Post your comment

Subject:
Message:
0/1000 characters