|
以下代码是获取某文件夹内文件名并写入表的代码,但是每次都少一条记录(也就是少一个文件名),我检查了N遍,还是找不到错在哪里?求帮忙!
Function GetFileList(strFilePathName As String) As String
Dim strDir As String
If Dir(strFilePathName) = "" Then
GetFileList = ""
Exit Function
End If
strDir = Dir(strFilePathName)
Do
strDir = Dir
i = i + 1
If strDir = "" Then Exit Do
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("select * from 调取文件名;")
With rs
.AddNew
!文件名 = Mid(strDir, 1, InStr(strDir, ".") - 1)
!文件类型 = Mid(strDir, InStr(strDir, ".") + 1, Len(strDir))
.Update
End With
rs.Close
Set rs = Nothing
Loop
End Function
|
|