Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse GetAttr to get a file's attributes
KeywordsGetAttr, function, file, attributes
CategoriesFiles and Directories
 
The GetAttr function returns a bit mask giving file properties. Combine this value with the constants vbNormal, vbReadOnly, etc. using And to see which attributes the file has.
 
Private Sub Command1_Click()
Dim result As Long

    result = GetAttr(txtFile.Text)
    lblResult.Caption = "&&H" & Hex$(result)

    If result And vbNormal Then
        chkNormal.Value = vbChecked
    Else
        chkNormal.Value = vbUnchecked
    End If
    If result And vbReadOnly Then
        chkReadOnly.Value = vbChecked
    Else
        chkReadOnly.Value = vbUnchecked
    End If
    If result And vbHidden Then
        chkHidden.Value = vbChecked
    Else
        chkHidden.Value = vbUnchecked
    End If
    If result And vbSystem Then
        chkSystem.Value = vbChecked
    Else
        chkSystem.Value = vbUnchecked
    End If
    If result And vbDirectory Then
        chkDirectory.Value = vbChecked
    Else
        chkDirectory.Value = vbUnchecked
    End If
    If result And vbArchive Then
        chkArchive.Value = vbChecked
    Else
        chkArchive.Value = vbUnchecked
    End If
End Sub
 
Formatted by Neil Crosby
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated