|
-
Nov 22nd, 2000, 05:20 AM
#1
Thread Starter
Addicted Member
I have a load of file in a directory. How do I write all of the file names that are contained in that folder and all subfolders to a database table. Thanks for any help that anyone may be able to offer.
-
Nov 22nd, 2000, 06:12 AM
#2
Lively Member
hi,
add a filelist box control and try this code
Dim ictr As Integer
File1.Path = App.Path
For ictr = 0 To File1.ListCount - 1
MsgBox File1.List(ictr)
'update ur field with this code
'filedname = file1.list(ictr)
Next ictr
-
Nov 22nd, 2000, 07:18 AM
#3
Fanatic Member
You can use the Dir command to loop through a directory listing. This will return a string representing the file name. If you check the attributes, you can decide which are sub-directories and recurese into those (i.e. pick up sub-directories of sub-directories).
Check out Dir() in VB Help, there are some good examples.
Cheers,
P.
Not nearly so tired now...
Haven't been around much so be gentle...
-
Nov 22nd, 2000, 07:24 AM
#4
_______
<?>
[code[
Option Explicit
Private Sub Command1_Click()
Dim myDir As String
myDir = "C:\AWay"
Call ProcessDir(myDir)
End Sub
Public Sub ProcessFiles(d As String)
List1.AddItem d
End Sub
Public Sub ProcessDir(strDir As String)
Dim i
Dim iCount As Integer
Dim FileList() As String
Dim Result As String
iCount = 0
Result = Dir(strDir & "\*.*", vbDirectory)
Do While Result <> "" ' Start the loop.
If Result <> "." And Result <> ".." Then
iCount = iCount + 1
ReDim Preserve FileList(1 To iCount)
FileList(iCount) = strDir & "\" & Result
End If
Result = Dir
Loop
' For i = 1 To iCount
For i = LBound(FileList) To UBound(FileList)
If (GetAttr(FileList(i)) And vbDirectory) = vbDirectory Then
ProcessDir (FileList(i))
Else
ProcessFiles (FileList(i))
End If ' it represents a directory.
Next
End Sub
[/code]
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|