本帖最后由 yu2n 于 2017-6-7 20:13 编辑
- ---------------------------
- 提示
- ---------------------------
- 目錄位置:C:\Users\Yu2n
-
- 掃尋完成,共有 5 個隱藏文件。是否刪除?
- ---------------------------
- 是(Y) 否(N) 取消
- ---------------------------
复制代码
- Const HIDDEN = 2 '指定隱藏屬性的文件
- Const PATH = "." '指定文件目錄
-
- Dim oItems, oFile, nCount : nCount = 0
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set oItems = fso.GetFolder(PATH)
- For Each oFile In oItems.Files
- If oFile.Attributes And HIDDEN Then
- nCount = nCount + 1
- End If
- Next
- If nCount > 0 Then
- If Msgbox("目錄位置:" & oItems.Path & vbCrLf & vbCrLf & _
- "掃尋完成,共有 " & nCount & " 個隱藏文件。是否刪除?", _
- vbQuestion+vbYesNoCancel+vbDefaultButton2, "提示") = vbYes Then
- For Each oFile In oItems.Files
- If oFile.Attributes And HIDDEN Then
- fso.DeleteFile oFile.Path, True
- End If
- Next
- End If
- Else
- Msgbox "目錄位置:" & oItems.Path & vbCrLf & vbCrLf & "掃尋完成,沒有發現隱藏文件。", _
- vbInformation, "提示"
- End If
复制代码
|