Any Idea on the best way to get a list of files from a directory into an array
would be?

Scott

12-18-2001, 05:06 PM

Karl E. Peterson

Re: Getting a list of files into an array

Direct assignment?
--
[Microsoft Basic: 1976-2001, RIP]

"Scott" <srr@gksys.com> wrote in message news:3c1f76bd@147.208.176.211...
>
> Any Idea on the best way to get a list of files from a directory into an array
> would be?
>
> Scott

12-18-2001, 05:06 PM

Karl E. Peterson

Re: Getting a list of files into an array

Direct assignment?
--
[Microsoft Basic: 1976-2001, RIP]

"Scott" <srr@gksys.com> wrote in message news:3c1f76bd@147.208.176.211...
>
> Any Idea on the best way to get a list of files from a directory into an array
> would be?
>
> Scott

12-19-2001, 03:45 PM

Scott

Re: Getting a list of files into an array

What?

"Karl E. Peterson" <karl@mvps.org> wrote:
>Direct assignment?
>--
>[Microsoft Basic: 1976-2001, RIP]
>
>
>"Scott" <srr@gksys.com> wrote in message news:3c1f76bd@147.208.176.211...
>>
>> Any Idea on the best way to get a list of files from a directory into
an array
>> would be?
>>
>> Scott
>

12-19-2001, 03:45 PM

Scott

Re: Getting a list of files into an array

What?

"Karl E. Peterson" <karl@mvps.org> wrote:
>Direct assignment?
>--
>[Microsoft Basic: 1976-2001, RIP]
>
>
>"Scott" <srr@gksys.com> wrote in message news:3c1f76bd@147.208.176.211...
>>
>> Any Idea on the best way to get a list of files from a directory into
an array
>> would be?
>>
>> Scott
>

12-19-2001, 05:37 PM

Karl E. Peterson

Re: Getting a list of files into an array

Assign the filenames to array elements as you arrive at them, eh? Guess all I was
saying is there aren't any magic bullets, here. Sorry...
--
[Microsoft Basic: 1976-2001, RIP]

Here's a wrapper class I've been tinkering with for a while that you may
or may not find helpful:

----class DirXP----
' Class DirXP Copyright 2001 Joseph L. Foster
' While it does the same job as Dir, it's not quite upwardly compatible.
' Do whatever you like with this so long as you remember Who's your Daddy!

Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

Private Const MAX_PATH = 260

Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type

Private FindHandle As Long
Private FindBuf As WIN32_FIND_DATA
Private Pattern As String
Private AttrMatchAll As Long, AttrMatchNone As Long

' WARNING: Barfs on directory and share names which VB's built-in Dir accepts.
' This doesn't handle vbVolume but instead pretends there is no volume label.
' To get (for example) only system directories which may or may not be hidden,
' use Dir("*", vbDirectory Or vbHidden Or vbSystem, vbDirectory or vbSystem)
Public Function Dir(Optional ByVal PathName As String = vbNullString, _
Optional ByVal Attributes As VbFileAttribute = vbNormal, _
Optional ByVal AttrGetOnly As VbFileAttribute = vbNormal) As String

Public Function FileLen() As Long
If FindHandle = INVALID_HANDLE_VALUE Then Err.Raise 5
If FindBuf.nFileSizeHigh <> 0 Or FindBuf.nFileSizeLow < 0 Then Err.Raise 6
FileLen = FindBuf.nFileSizeLow
End Function

Here's a wrapper class I've been tinkering with for a while that you may
or may not find helpful:

----class DirXP----
' Class DirXP Copyright 2001 Joseph L. Foster
' While it does the same job as Dir, it's not quite upwardly compatible.
' Do whatever you like with this so long as you remember Who's your Daddy!

Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

Private Const MAX_PATH = 260

Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type

Private FindHandle As Long
Private FindBuf As WIN32_FIND_DATA
Private Pattern As String
Private AttrMatchAll As Long, AttrMatchNone As Long

' WARNING: Barfs on directory and share names which VB's built-in Dir accepts.
' This doesn't handle vbVolume but instead pretends there is no volume label.
' To get (for example) only system directories which may or may not be hidden,
' use Dir("*", vbDirectory Or vbHidden Or vbSystem, vbDirectory or vbSystem)
Public Function Dir(Optional ByVal PathName As String = vbNullString, _
Optional ByVal Attributes As VbFileAttribute = vbNormal, _
Optional ByVal AttrGetOnly As VbFileAttribute = vbNormal) As String

Public Function FileLen() As Long
If FindHandle = INVALID_HANDLE_VALUE Then Err.Raise 5
If FindBuf.nFileSizeHigh <> 0 Or FindBuf.nFileSizeLow < 0 Then Err.Raise 6
FileLen = FindBuf.nFileSizeLow
End Function