【VB】VB详细枚举指定目录、文件夹文件列表

admin 2021年4月3日19:01:57评论52 views字数 2552阅读8分30秒阅读模式

    VB 详细枚举指定目录、文件夹文件列表,VB 详细枚举指定目录文件列表,VB 详细枚举指定文件夹文件列表,VB 枚举指定目录文件列表,VB 枚举指定文件夹文件列表,VB 枚举 目录、文件夹文件列表,VB 枚举 目录文件列表,VB 枚举 文件夹文件列表,VB 枚举 目录,VB 枚举 文件夹,VB 获取指定目录、文件夹文件详细列表,VB 获取指定目录、文件夹文件列表,VB 获取指定目录文件详细列表,VB 获取指定文件夹文件详细列表,VB 获取指定目录文件列表,VB 获取指定文件夹文件列表,VB 获取 目录、文件夹文件详细列表,VB 获取 目录、文件夹文件列表,VB 获取 目录文件列表,VB 获取 文件夹文件列表,VB 获取 目录、文件夹 列表,VB 获取 目录 列表,VB 获取 文件夹 列表,VB 目录 详细文件列表,VB 文件夹 详细文件列表,VB 目录 文件列表,VB 文件夹 文件列表,VB 目录 列表,VB 文件夹 列表。

VB详细枚举指定目录、文件夹文件列表:

Public Function TheFileAttr(P As String) As String                              '读取指定文件/文件夹属性
    On Error GoTo Over
    If (GetAttr(P) And vbNormal) = vbNormal Then TheFileAttr = "常规"
    If (GetAttr(P) And vbReadOnly) = vbReadOnly Then TheFileAttr = TheFileAttr & "+只读"
    If (GetAttr(P) And vbHidden) = vbHidden Then TheFileAttr = TheFileAttr & "+隐藏"
    If (GetAttr(P) And vbSystem) = vbSystem Then TheFileAttr = TheFileAttr & "+系统"
    If (GetAttr(P) And vbDirectory) = vbDirectory Then TheFileAttr = TheFileAttr & "+目录"
    If (GetAttr(P) And vbArchive) = vbArchive Then TheFileAttr = TheFileAttr & "+存档"
    If (GetAttr(P) And vbAlias) = vbAlias Then TheFileAttr = TheFileAttr & "+别名"
    Exit Function
Over:
    TheFileAttr = "无法识别"
End Function

Public Function DirList(P As String) As String                                  '详细枚举指定路径下的文件
    On Error Resume Next                                                        '只能用强行排错兼容某些特殊文件。
    Dim NowList As String, DList As String, FList As String, Thelen As String   '当前列表,列表列表,文件列表,文件/目录大小,属性
    If Right(P, 1) "" Then P = P & ""                                      '判断最后一位是否为"",添加""防止搜索出错
    NowList = Dir(P, vbHidden + vbNormal + vbReadOnly + vbSystem + vbDirectory) '枚举目录列表
    While NowList ""                                                         '搜索当前目录,直到结果为空
        If NowList "." And NowList ".." Then                              '排除上级目录和当前目录
            If (GetAttr(P & NowList) And vbDirectory) vbDirectory Then       '判断属性
                Thelen = FileLen(P & NowList)                                   '获取文件大小
                If Thelen
                FList = FList & NowList & "|文件|" & Thelen & "|" & TheFileAttr(P & NowList) & "|" & FileDateTime(P & NowList) & vbCrLf '如果找到的是文件,则累加文件'文件名,类型,大小,属性,创建日期
            Else
                DList = DList & NowList & "|文件夹|0 KB|" & TheFileAttr(P & NowList) & "|" & FileDateTime(P & NowList) & vbCrLf '如果找到的是目录,则累加目录'文件名,类型,大小,属性,创建日期
            End If
        End If
        NowList = Dir()                                                         '继续获取
    Wend
    DirList = DList & FList
Over:
    If Len(DirList) = 0 Then DirList = "查找错误,或目录不存在!,或目录为空!"
End Function

Private Sub Command1_Click()
    MsgBox DirList("c:")
End Sub

文章来源于lcx.cc:【VB】VB详细枚举指定目录、文件夹文件列表

相关推荐: BackTrack 邮件日掉对方机器反弹CmdShell

    http://backtrack.it/ 这个国外网站有视频演示过了的。     要期末开始了,虽然控制了整个学校的网络啥的,但是还是没弄到期末考试试题!于是就想通过邮箱来干掉老师的电脑然后窃取期末试题(玩笑话啊,不要当真),开始上菜。 MY Comp…

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年4月3日19:01:57
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【VB】VB详细枚举指定目录、文件夹文件列表https://cn-sec.com/archives/319667.html

发表评论

匿名网友 填写信息