Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

File properties (size/date/attributes)


'file length (Bytes) - use full path name unless file is in current drive/directory
Dim iLength As Long
iLength = FileLen( "c:\filename.exe" )

'date/time of a file
Dim temp As Variant
Dim FileName As String
FileName = "c:\data\test.txt"
temp = FileDateTime (FileName)

'attributes of a file
Function FileProperties( FileName As String , RO As Boolean , Hidden As Boolean , System As Boolean , Directory As Boolean , Archive As Boolean )
    Dim iResult As Long
   iResult = GetAttr (FileName)
   RO = iResult And vbReadOnly
   Hidden = iResult And vbHidden
   System = iResult And vbSystem
   Directory = iResult And vbDirectory
   Archive = iResult And vbArchive
   FileProperties = iResult
End Function

'set the attributes of a file (file cannot be open)
SetAttr "c:\test.txt" , vbNormal + vbReadOnly + vbHidden + vbSystem + vbArchive