Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Jan 2002
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Directory searching (VB 6)

    Hi

    I have been given some code to search all IE Favorites The program works well in at least Win 95, Win 98 and Win NT4, but not in Win XP HE. Here it searches the root directory but not the lower directories. My VB skills are limited so any help is appreciated. Here is the code

    'Set start path and values
    Dim vlDirMatrix() As String 'Dir Path matrix
    Dim vlMatrixIndex As Long 'Matrix position

    For vlCont = 0 To 1

    ReDim vlDirMatrix(0) 'Reset subdirs container
    vlMatrixIndex = -1 'Reset subdirs pointer

    If (vgDoMSIE = cgYES) And (vlCont = 0) Then vlDirMatrix(UBound(vlDirMatrix)) = vgMSIEMain
    If (vgDoMSIEEx = cgYES) And (vlCont = 1) Then vlDirMatrix(UBound(vlDirMatrix)) = vgMSIEAlt

    If ((vgDoMSIE = cgYES) And (vlCont = 0)) Or ((vgDoMSIEEx = cgYES) And (vlCont = 1)) Then

    'DEBUG
    subDebug cgINFO, "Reading MSIE Dir: " & vlDirMatrix(UBound(vlDirMatrix))
    vlTimer = Timer
    subDebug cgSTART, "Start Directory Reading: " & Str(vlTimer)

    On Error Resume Next
    While (vlMatrixIndex <> UBound(vlDirMatrix))
    vlMatrixIndex = vlMatrixIndex + 1
    vlTmpStr = Dir(vlDirMatrix(vlMatrixIndex), vbDirectory)
    'I'm searching for (sub)dirs and files
    While (vlTmpStr <> "")
    If LCase(Right(vlTmpStr, 4)) = ".url" Then
    'is file, so... search for the string
    Select Case vgSearch
    Case cgNAME:
    If InStr(LCase(Left(vlTmpStr, Len(vlTmpStr) - 4)), vlSearch) <> 0 Then
    vlFound = True
    vmFileMatrix(UBound(vmFileMatrix)).vName = vlDirMatrix(vlMatrixIndex) & vlTmpStr
    ReDim Preserve vmFileMatrix((UBound(vmFileMatrix) + 1))
    End If
    Case cgURL:
    vlTmpURL = funGetURL(vlDirMatrix(vlMatrixIndex) & vlTmpStr)
    If InStr(LCase(vlTmpURL), vlSearch) <> 0 Then
    vlFound = True
    vmFileMatrix(UBound(vmFileMatrix)).vName = vlDirMatrix(vlMatrixIndex) & vlTmpStr
    vmFileMatrix(UBound(vmFileMatrix)).vURL = vlTmpURL
    ReDim Preserve vmFileMatrix((UBound(vmFileMatrix) + 1))
    End If
    Case cgBOTH:
    vlTmpURL = funGetURL(vlDirMatrix(vlMatrixIndex) & vlTmpStr)
    If (InStr(LCase(vlTmpURL), vlSearch) <> 0) Or (InStr(LCase(Left(vlTmpStr, Len(vlTmpStr) - 4)), vlSearch)) Then
    vlFound = True
    vmFileMatrix(UBound(vmFileMatrix)).vName = vlDirMatrix(vlMatrixIndex) & vlTmpStr
    vmFileMatrix(UBound(vmFileMatrix)).vURL = vlTmpURL
    ReDim Preserve vmFileMatrix((UBound(vmFileMatrix) + 1))
    End If
    End Select
    ElseIf GetAttr(vlDirMatrix(vlMatrixIndex) & vlTmpStr) = vbDirectory Then
    'is dir
    If (vlTmpStr <> ".") And (vlTmpStr <> "..") Then
    ReDim Preserve vlDirMatrix(UBound(vlDirMatrix) + 1)
    vlDirMatrix(UBound(vlDirMatrix)) = vlDirMatrix(vlMatrixIndex) & vlTmpStr & ""
    End If
    End If
    vlTmpStr = Dir
    Wend
    Wend

    'DEBUG
    vlTimer = Timer
    subDebug cgEND, "Directory Reading Done: " & Str(vlTimer)

    End If
    Next vlCont
    'MSIE END!'MSIE END!'MSIE END!'MSIE END!'MSIE END!'MSIE END!'MSIE END!


    Thanks

    Chris

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Directory searching (VB 6)

    You must not have given us enough of your code. I cannot get it to compile and I cannot understand it well enough to analyze it without single-stepping through the code. --Sam
    Attached Images Attached Images
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    Lounger
    Join Date
    Jan 2002
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Directory searching (VB 6)

    Hi

    The whole program is large. I beleive that the directory part is

    ElseIf GetAttr(vlDirMatrix(vlMatrixIndex) & vlTmpStr) = vbDirectory Then
    'is dir
    If (vlTmpStr <> ".") And (vlTmpStr <> "..") Then
    ReDim Preserve vlDirMatrix(UBound(vlDirMatrix) + 1)
    vlDirMatrix(UBound(vlDirMatrix)) = vlDirMatrix(vlMatrixIndex) & vlTmpStr & ""
    End If
    End If
    vlTmpStr = Dir


    Is there are problem with this section

    Thanks

  4. #4
    Lounger
    Join Date
    Jan 2002
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Directory searching (VB 6)

    I have isloated the problem to the Get

    From the following code

    Private Sub Form_Load()
    aa = GetAttr("c:1")
    bb = GetAttr("C:UserFavorites1a")
    cc = GetAttr("f:1")
    dd = vbDirectory
    End Sub

    I get the values aa = 8209, bb = 8208, cc = 16 & dd= 16.

    If seems that for the f: drive (a partition) I get 16 for all directories but for the c: drive I get a variety of answers?

    I am comfused?

    Any suggestions?

    Thanks

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Directory searching (VB 6)

    A folder can have several attributes; the bit flags for these are added to get the Attributes value. For instance, the Read-Only property is 1, so a read-onlt folder will have attributes 16+1=17.
    To find out whether your string represents a folder, use GetAttr(...) And 16. If this value is 16, ... is a folder; otherwise, it isn't.

  6. #6
    Lounger
    Join Date
    Jan 2002
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Directory searching (VB 6)

    Hi

    Thanks for the suggestions.

    I changed the = to And and it works correctly on Win XP HE

    Thanks again

Posting Permissions

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