Jump to content

Is it a folder?


erifash
 Share

Recommended Posts

Here is a quick little function that checks to see if a path belongs to a folder or not:

; Return - Path is folder: True, Path is file: False

Func _IsFolder( $sPath )
    If not FileExists($sPath) Then SetError(1)
    Return not not StringInStr(FileGetAttrib($sPath), "D")
EndFunc

Enjoy!

Link to comment
Share on other sites

I put that in there because I didn't want a number to be returned, but True or False (boolean). You can remove it if you don't like it.

Link to comment
Share on other sites

Here is a quick little function that checks to see if a path belongs to a folder or not:

; Return - Path is folder: True, Path is file: False

Func _IsFolder( $sPath )
    If not FileExists($sPath) Then SetError(1)
    Return not not StringInStr(FileGetAttrib($sPath), "D")
EndFunc

Enjoy!

@erifash, just found a use for your function.. Thanks for the post.. I gave you some stars!! :o

Cheers.. B)

Link to comment
Share on other sites

I made something a while ago, that is not reliable, but at the time I thought it was.

Func _FileOrFolder($path)
   Local $len = StringLen($path)
   If StringMid($path, $len) = "\" Then
      MsgBox(0, "Folder", $path & " is a folder.")
   Else
      MsgBox(0, "File", $path & " is a file.")
   EndIf
EndFunc  ;==>FileOrFolder

_FileOrFolder("C:\Program Files\AutoIt3\AutoIt3.exe")
_FileOrFolder("C:\")

EDIT: The MsgBox's were just for debugging purposes.

Edited by layer
FootbaG
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...