Home > How-To Library > File/Folders Handling

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

**************************************************************** * © 2007 CodeItBetter http://www.codeitbetter.com * * This notice MUST stay intact for legal use * ****************************************************************
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

If you would like to submit your code here please us. Do not forget to mention your name. We are always thankful to each and everyone of you who submitted their code here.