Webson
|
| Posted: 04/10/2002, 2:14 PM |
|
Hi all,
Anyone help on this one.
I want to get a list of the contents of a folder into a DB without =
manually entering each one.
ie I have a folder with 750 files and want to list them in an Access DB.
Help would be appreciated.
|
|
|
 |
MJH
|
| Posted: 04/11/2002, 4:06 AM |
|
' some vb code for this >>>>
'
path = Server.MapPath( DIRECTORY ) ''DIRECTORY is relative path in virtual
directories ( from root )
Set fso = CreateObject("Scripting.FileSystemObject")
Set theCurrentFolder = fso.GetFolder( path )
Set curFiles = theCurrentFolder.Files
'
' And now a loop for the files
'
Dim theFiles( )
ReDim theFiles( 500 ) ' arbitrary size!
currentSlot = -1 ' start before first slot
' We collect all the info about each file and put it into one
' "slot" in our "theFiles" array.
'
For Each fileItem in curFiles
fname = fileItem.Name
fext = InStrRev( fname, "." )
If fext < 1 Then fext = "" Else fext = Mid(fname,fext+1)
ftype = fileItem.Type
fsize = fileItem.Size
fcreate = fileItem.DateCreated
fmod = fileItem.DateLastModified
faccess = fileItem.DateLastAccessed
currentSlot = currentSlot + 1
If currentSlot > UBound( theFiles ) Then
ReDim Preserve theFiles( currentSlot + 99 )
End If
' note that what we put here is an array!
theFiles(currentSlot) =
Array(fname,fext,ftype,fsize,fcreate,fmod,faccess)
Next
'
' files are now in the array...
mjh
Webson <webson@blueyonder.co.uk> wrote in message
news:a92a0c$e27$1@news.codecharge.com...
Hi all,
Anyone help on this one.
I want to get a list of the contents of a folder into a DB without manually
entering each one.
ie I have a folder with 750 files and want to list them in an Access DB.
Help would be appreciated.
|
|
|
 |
Webson
|
| Posted: 04/11/2002, 5:53 AM |
|
Thanks for that, I'll give it a go.
"MJH" <AnswerInNewsgroupPlease@no.spam.please> wrote in message =
news:a93qmt$c8b$1@news.codecharge.com...
> ' some vb code for this >>>>
> '
> path =3D Server.MapPath( DIRECTORY ) ''DIRECTORY is relative path in =
virtual
> directories ( from root )
>=20
> Set fso =3D CreateObject("Scripting.FileSystemObject")
> Set theCurrentFolder =3D fso.GetFolder( path )
> Set curFiles =3D theCurrentFolder.Files
> '
> ' And now a loop for the files
> '
> Dim theFiles( )
> ReDim theFiles( 500 ) ' arbitrary size!
> currentSlot =3D -1 ' start before first slot
>=20
> ' We collect all the info about each file and put it into one
> ' "slot" in our "theFiles" array.
> '
> For Each fileItem in curFiles
> fname =3D fileItem.Name
> fext =3D InStrRev( fname, "." )
> If fext < 1 Then fext =3D "" Else fext =3D Mid(fname,fext+1)
> ftype =3D fileItem.Type
> fsize =3D fileItem.Size
> fcreate =3D fileItem.DateCreated
> fmod =3D fileItem.DateLastModified
> faccess =3D fileItem.DateLastAccessed
> currentSlot =3D currentSlot + 1
> If currentSlot > UBound( theFiles ) Then
> ReDim Preserve theFiles( currentSlot + 99 )
> End If
> ' note that what we put here is an array!
> theFiles(currentSlot) =3D
> Array(fname,fext,ftype,fsize,fcreate,fmod,faccess)
> Next
> '
> ' files are now in the array...
>=20
>=20
> mjh
>=20
> Webson <webson@blueyonder.co.uk> wrote in message
>news:a92a0c$e27$1@news.codecharge.com...
> Hi all,
>=20
> Anyone help on this one.
> I want to get a list of the contents of a folder into a DB without =
manually
> entering each one.
> ie I have a folder with 750 files and want to list them in an Access =
DB.
> Help would be appreciated.
>=20
>=20
>=20
|
|
|
 |
|