if dir("文件夹\*.*")="" then 为空

解决方案 »

  1.   

    引用Microsoft Scripting Runtime
    dim folder as scripting.folder
    然后把folder指向你的文件夹
    再根据folder.subfolder.count以及folder.files.count是否为0来判断
      

  2.   

    方法2:利用File System Object(文件系统对象-FSO)  Dim fs, f, f1, fc, s
      Set fs = CreateObject("Scripting.FileSystemObject")
      Set f = fs.GetFolder(文件夹)
      Set fc = f.Files
      if fc.count=0 then 文件夹为空
      

  3.   

    Private Sub Command1_Click()
        Dim fs, f, f1, fc, s
        Set fs = CreateObject("Scripting.FileSystemObject")
        Set f = fs.GetFolder("C:\")
        Set fc = f.Files    For Each f1 In fc
            s = s & f1.Name
            s = s & vbCrLf
        Next    MsgBox s
        MsgBox fc.Count'此处为文件夹中文件的个数。
    End Sub