Results 1 to 4 of 4

Thread: [RESOLVED] API Way to see if a path is folder or file?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2008
    Posts
    84

    Resolved [RESOLVED] API Way to see if a path is folder or file?

    hello,

    i tried google'ing around but that didnt helped much, i am looking for some way to check if a location on widdows system is a file or directory,

    i am working with some program that comes up with filename with no extension so i just wanted to know a way to find how to differentiate them as file or folder only api way .

    regards
    raj

  2. #2
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: API Way to see if a path is folder or file?

    Code:
    Private Declare Function PathIsDirectory Lib "shlwapi.dll" Alias "PathIsDirectoryA" (ByVal sPath As String) As Long
    
    Private Sub Command1_Click()
    MsgBox CBool(PathIsDirectory("C:\Documents and Settings"))
    End Sub
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  3. #3
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: API Way to see if a path is folder or file?

    A non-API alternative.
    Code:
    Private Sub Command1_Click()
        MsgBox IsDirectory("C:\PIS\") 'true
        MsgBox IsDirectory("C:\PIS\Untitled.png") 'false
    End Sub
    
    Private Function IsDirectory(ByVal sFile As String) As Boolean
        IsDirectory = (GetAttr(sFile) And vbDirectory) = vbDirectory
    End Function
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Aug 2008
    Posts
    84

    Re: API Way to see if a path is folder or file?

    ty seenu_1st !!

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