Jump to content

Recommended Posts

Posted

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!

Posted

Isn't this

Return not not StringInStr(FileGetAttrib($sPath), "D")

the same as

Return StringInStr(FileGetAttrib($sPath), "D")

I thought that 2 nots would cancel each other out?

Posted

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)

Posted (edited)

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

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
×
×
  • Create New...