Results 1 to 4 of 4

Thread: Check if file or folder *RESOLVED*

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    54

    Talking Check if file or folder *RESOLVED*

    Hello,
    I need to check if a path specified is file or folder/volume... all "FileExists" functions I found return True if I pass them a folder path... how do I check if path is folder or file?

    thanks in advance,
    Darko
    Last edited by Darkolord; May 25th, 2004 at 07:38 AM.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    If you have at least IE4, you can use PathIsDirectory...
    VB Code:
    1. Private Declare Function PathIsDirectory Lib "shlwapi.dll" Alias "PathIsDirectoryA" (ByVal sPath As String) As Long
    2.  
    3. Private Sub Command1_Click()
    4.     MsgBox CBool(PathIsDirectory("c:\users"))
    5. End Sub
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    54
    Perfect...

    thanks!

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Or you can do :

    VB Code:
    1. Dir$(FilePath, vbDirectory)

    to see if it's a valid dir... Although the API way is definatelly better


    Has someone helped you? Then you can Rate their helpful post.

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