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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get file details on hard disk

Status
Not open for further replies.

sarah77

Programmer
Jun 4, 2002
36
0
0
US
I want to do this:
- Check if a certain directory exist on a hard disk ?
- Check if a certain file exist on a hard disk ?
- Get the file name,file date,file time exist in a certain folder on hard disk.

Thanks for any comment
 
Use the FSO [File system object] object. That'll give you access to what you want to do.
 
Here is some code to get you started

Private Sub cmdExist_Click()
Dim fso As New FileSystemObject
Dim fFolder As Folder
Dim sFolder As String
Dim sFile As String
Dim sInfo As String

sFolder = "I:\Projects"
sFile = sFolder & "\Newt.txt"
Set fFolder = fso.GetFolder("c:")
If fso.FolderExists(sFolder) Then
MsgBox "Folder Exists"
If fso.FileExists(sFile) Then
MsgBox "File Exists"
sInfo = "File Version " & fso.GetFileVersion(sFile) & vbCrLf
MsgBox sInfo
Else
MsgBox "File Does Not Exists"
End If
Else
MsgBox "Folder Does Not Exists"
End If
End Sub

You will need to add a reference to the Microsoft Scripting Runtime Library. Hope this Helps. Anything is possible, the problem is I only have one lifetime.
[cheers]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top