Results 1 to 7 of 7

Thread: Which variables?

  1. #1

    Thread Starter
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692

    Which variables?

    How would I go about importing a drive's contents into a List View control without the use of a file list box? I know how to put them in their respective columns, I just need to know what API files and variables to use.

  2. #2
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    Is API necessary?

  3. #3
    Frenzied Member macai's Avatar
    Join Date
    Jul 2001
    Location
    Napanoch NY
    Posts
    1,228
    I think you can do that with FSO...
    Luke

  4. #4
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    Yeah.. you can always do it with Scripting Library...aka File System Objects

  5. #5
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Originally posted by moinkhan
    Yeah.. you can always do it with Scripting Library...aka File System Objects
    Just to be a dickhead, I'm gonna point out that the FSO is just one part of the Scripting library - they're not one and the same thing.
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  6. #6
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    to get files from a folder:
    VB Code:
    1. Function FilesInPath(strDir As String) As String()
    2.     'returns a 0 based array with the directories in strDir
    3.     Dim Count As Integer
    4.     Dim sFiles() As String
    5.     Dim sFile As String
    6.    
    7.     If Right(strDir, 1) <> "\" Then strDir = strDir & "\"
    8.  
    9.     sFile = Dir$(strDir, vbDirectory)
    10.     Count = -1
    11.     Do
    12.         If sFile <> "." And sFile <> ".." Then
    13.             If (GetAttr((strDir & sFile)) And vbDirectory) <> vbDirectory Then
    14.                 Count = Count + 1
    15.                 ReDim Preserve sFiles(Count)
    16.                 sFiles(Count) = sFile
    17.             End If
    18.         End If
    19.    
    20.         sFile = Dir$
    21.     Loop Until sFile = ""
    22.     FilesInPath = sFiles
    23. End Function

    to get folders from a folder:

    VB Code:
    1. Function DirsInPath(strDir As String) As String()
    2.     'returns a 0 based array with the directories in strDir
    3.     Dim Count As Integer
    4.     Dim sFiles() As String
    5.     Dim sFile As String
    6.    
    7.     If Right(strDir, 1) <> "\" Then strDir = strDir & "\"
    8.    
    9.     sFile = Dir$(strDir, vbDirectory)
    10.     Count = -1
    11.     Do
    12.         If sFile <> "." And sFile <> ".." Then
    13.             If (GetAttr((strDir & sFile)) And vbDirectory) Then
    14.                 Count = Count + 1
    15.                 ReDim Preserve sFiles(Count)
    16.                 sFiles(Count) = sFile
    17.             End If
    18.         End If
    19.        
    20.         sFile = Dir$
    21.     Loop Until sFile = ""
    22.     DirsInPath = sFiles
    23. End Function
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  7. #7
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    oh yeah.. it gives you an array, so for example loop through files in C and adds to listbox:

    dim a() as string
    dim i as long

    a = FilesInPath("C:\")
    for i = lbound(a) to ubound(a)
    list1.additem a(i)
    next i
    Remember, if someone's post was not helpful, you can always rate their post negatively .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width