Procedura za citanje atributov:
Sub ShowFiles()
' Displays the names and attributes of all files in
' the specifed directory
Dim sAttr As Integer
Dim fName As String
Dim pName As String
Dim fCount As Integer
pName = InputBox("Enter a directory to search in: ")
If Trim(pName) = " " Then Exit Sub
If Right(pName, 1) <> "\" Then pName = pName & "\"
sAttr = vbDirectory + vbArchive + vreadonly + _
vbHidden + vbSystem
'get the first file name and atributes
fName = Dir(pName & "*.*", sAttr)
If (fName <> " ") And _
((fName <> ".") And (fName <> "..")) Then
ShowFileAttr pName & fName
fCount = 1
End If
Do While (fName <> " ")
fName = Dir()
If ((fName <> ".") And (fName <> ".")) Then
ShowFileAttr pName & fName
fCount = fCount + 1
End If
Loop
MsgBox fCount & " files found."
End Sub
Sub ShowFileAttr(fName As String)
'displays a message box showing the file attributes of the
'filename in the fName argument
Dim fAttr As Integer
Dim mStr As String
fAttr = GetAttr(fName)
mStr = UCase(fName)
mStr = mStr & " has these attributes: " & vbCr
If (fAttr And vbReadOnly) Then _
mStr = mStr & "Read-Only" & vbCr
If (fAttr And vbHidden) Then _
mStr = mStr & "Hidden" & vbCr
If (fAttr And vbSystem) Then
mStr = mStr & "system" & vbCr
If (fAttr And vbVolume) Then _
mStr = mStr & "Volume" & vbCr
If (fAttr And vbDirectory) Then _
mStr = mStr & "Directory" & vbCr
If (fAttr & vbArchive) Then _
mStr = mStr & "Archive" & vbCr
End If
MsgBox mStr
End Sub
Sad samo obratni postupak.
|