erifash Posted November 5, 2005 Share Posted November 5, 2005 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! My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
hankjrfan Posted November 5, 2005 Share Posted November 5, 2005 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? Link to comment Share on other sites More sharing options...
erifash Posted November 5, 2005 Author Share Posted November 5, 2005 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. My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
hankjrfan Posted November 5, 2005 Share Posted November 5, 2005 That is kind of cool I was not aware that "noting" it made it a bool. That is good to know. Link to comment Share on other sites More sharing options...
busysignal Posted November 5, 2005 Share Posted November 5, 2005 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") EndFuncEnjoy!@erifash, just found a use for your function.. Thanks for the post.. I gave you some stars!! Cheers.. Link to comment Share on other sites More sharing options...
erifash Posted November 5, 2005 Author Share Posted November 5, 2005 You're welcome! My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
layer Posted November 5, 2005 Share Posted November 5, 2005 (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 November 5, 2005 by layer FootbaG Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now