CodeItBetter Programming Another VB Programming Blog

How to return a string containing all possible information about the file

Posted on July 1, 2011
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'File/Folder Handling - How to return a string containing all possible information about the file
Public Function FileInfo(FileName) As String
    Dim File As String
    Dim Temp As String
    Dim Attrib As Integer
 
    File = FileName
    ' Use GetAttr function to get all attributes info
    Attrib = GetAttr(File)
    Temp = File & vbCrLf & vbCrLf
    Temp = Temp & "Date/Time: " & FileDateTime(File) & vbCrLf
    Temp = Temp & "Size: " & FileLen(File) & " bytes" & vbCrLf
    'Test for read only attribute by masking bits
    If (Attrib And vbReadOnly) = vbReadOnly Then
        Temp = Temp & "ReadOnly: X" & vbCrLf
    End If
    ' Test for hidden attribute
    If (Attrib And vbHidden) = vbHidden Then
        Temp = Temp & "Hidden: X" & vbCrLf
    End If
    ' Test for system attribute
    If (Attrib And vbSystem) = vbSystem Then
        Temp = Temp & "System: X" & vbCrLf
    End If
    ' Test for archive attribute
    If (Attrib And vbArchive) = vbArchive Then
        Temp = Temp & "Archive: X" & vbCrLf
    End If
    ' Return Temp string containing all file info
    FileInfo = Temp
End Function
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.