Results 1 to 5 of 5

Thread: How can I check if an object in a listview is a file or a folder?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195
    Anyone know?

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Code:
    ' assumes you are looking in a specific directory, say strDirectory = "C:\"
    
      If Dir$(strDirectory & ListView1.SelectedItem.Text, vbNormal Or vbHidden Or vbArchive Or vbSystem Or vbReadOnly) Then
        MsgBox "File"
      ElseIf Dir$(strDirectory & ListView1.SelectedItem.Text, vbDirectory) Then
        MsgBox "Folder"
      End If
    should work...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Or this, which you can change to fit your needs.

    Code:
    Private Sub Command1_Click()
        If GetAttr("C:\test") = vbDirectory Then
            MsgBox "Directory"
        ElseIf GetAttr("C:\test.txt") = vbNormal Then
            MsgBox "File"
        End If
    End Sub

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    another one of those damn functions that I didn't know about!! Megatron told me about SetAttr() or Save Attr() I forget which is right, I gues it only stood to reason that a Get Attr() function existed...Thanks for the info, Lethal
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    No problem, the one Megatron was referring to was SetAttr() function.

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