dir就可以 DirName = Dir(path, vbDirectory Or vbHidden Or vbArchive Or vbReadOnly _ Or vbSystem) ' Even if hidden, and so on. Do While Len(DirName) > 0 ' Ignore the current and encompassing directories. If (DirName <> ".") And (DirName <> "..") Then ' Check for directory with bitwise comparison. If GetAttr(path & DirName) And vbDirectory Then dirNames(nDir) = DirName DirCount = DirCount + 1 nDir = nDir + 1 ReDim Preserve dirNames(nDir) 'List2.AddItem path & DirName ' Uncomment to list End If ' directories. sysFileERRCont: End If DirName = Dir() ' Get next subdirectory. Loop
这是改文件属性的,具体怎么自己想吧! n = GetAttr("d:\a.txt") '修改文件属性 SetAttr "d:\a.txt", vbNormal ............ '恢复文件属性 SetAttr "d:\a.txt", n
DirName = Dir(path, vbDirectory Or vbHidden Or vbArchive Or vbReadOnly _
Or vbSystem) ' Even if hidden, and so on.
Do While Len(DirName) > 0
' Ignore the current and encompassing directories.
If (DirName <> ".") And (DirName <> "..") Then
' Check for directory with bitwise comparison.
If GetAttr(path & DirName) And vbDirectory Then
dirNames(nDir) = DirName
DirCount = DirCount + 1
nDir = nDir + 1
ReDim Preserve dirNames(nDir)
'List2.AddItem path & DirName ' Uncomment to list
End If ' directories.
sysFileERRCont:
End If
DirName = Dir() ' Get next subdirectory.
Loop
n = GetAttr("d:\a.txt")
'修改文件属性
SetAttr "d:\a.txt", vbNormal
............
'恢复文件属性
SetAttr "d:\a.txt", n