请问VB如何将本地的一个目录下的所有文件的文件名及其最后修改日期存到一个数组里?

解决方案 »

  1.   

    原来读取文件名是这样的呀Private Sub Command1_Click()
        Dim i As Integer
        Dim fs As Object
        Dim fc As Object
        Dim f As Object
        Dim array1() As String
        
        Set fs = CreateObject("Scripting.FileSystemObject")
        Set f = fs.GetFolder("e:\vbtemp")
        Set fc = f.Files
        i = 0
        
        For Each f In fc
            ReDim Preserve array1(i)
            array1(i) = f.Name
            i = i + 1
            Debug.Print f.Name
        Next
    End Sub但是获取修改时间还是不太会
      

  2.   

    原来是这样来获取文件修改时间Private Sub Command2_Click()
        Dim fs, f, s
        Set fs = CreateObject("Scripting.FileSystemObject")
        Set f = fs.GetFile("e:\vbtemp\123.txt")
        s = f.Name & " on Drive " & UCase(f.Drive) & vbCrLf
        s = s & "Created: " & f.DateCreated & vbCrLf
        s = s & "Last Accessed: " & f.DateLastAccessed & vbCrLf
        s = s & "Last Modified: " & f.DateLastModified
        MsgBox s, 0, "File Access Info"End Sub
      

  3.   

    很好了。
    DIR /T可以了
      

  4.   

    定义一个结构体
    public type FileInfo
      strFileName as string
      tFielDate as time
    End Typedim arrFile() as FileInfo然后把东西往里面塞撒