dim sTemp as string
dim sFileName(100) as string  '记录文件名
dim intTotal as integer  '文件总数
intTotal=0
sTemp=Dir$(Path & "\*.*")
do while sTemp<>""
   sFileName(intTotal)=sTemp
   intTotal=intTotal+1
   sTemp=Dir$
loop
   

解决方案 »

  1.   

    Dim MyFile, MyPath, MyName' 返回“WIN.INI” (如果该文件存在)。
    MyFile = Dir("C:\WINDOWS\WIN.ini")   ' 返回带指定扩展名的文件名。如果超过一个 *.ini 文件存在,
    ' 函数将返回按条件第一个找到的文件名。
    MyFile = Dir("C:\WINDOWS\*.ini")' 若第二次调用 Dir 函数,但不带任何参数,则函数将返回同一目录下的下一个 *.ini 文件。
    MyFile = Dir' 返回找到的第一个隐式 *.TXT 文件。
    MyFile = Dir("*.TXT", vbHidden)' 显示 C:\ 目录下的名称。
    MyPath = "c:\"   ' 指定路径。
    MyName = Dir(MyPath, vbDirectory)   ' 找寻第一项。
    Do While MyName <> ""   ' 开始循环。
       ' 跳过当前的目录及上层目录。
       If MyName <> "." And MyName <> ".." Then
          ' 使用位比较来确定 MyName 代表一目录。
          If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
             Debug.Print MyName   ' 如果它是一个目录,将其名称显示出来。
          End If
       End If
       MyName = Dir   ' 查找下一个目录。
    Loop可以在循环中记录文件数。
      

  2.   

    Private Sub Command1_Click()
    Dim MyPath, MyName
    dim intcount as longMyPath = "c:\"   ' 指定路径
    MyName = Dir(MyPath, vbSystem Or vbHidden Or vbNormal)
    Do While MyName <> ""
        Debug.Print MyName
        MyName = Dir
        intcount=intcount+1
    Loop
    debug.? intcount
    End Sub
      

  3.   

    使用FileSystemScript对象,这里面有对文件,文件夹和文件夹内容的操作
      

  4.   

    我就纳闷了
    好好的dirlist放在标准控建里干嘛不用?dir1.path=你的路径for i=0 to dir1.listcount-1
    dir1.list(i)'所有文件
    nextdir.listcount文件个数
      

  5.   

    create link to microsoft scrpting runtimedim f as file,fl as folderfor each f in fl.files
      msgbox f.name
    next fthank you
    By Morn