Jump to content

Ok wait.. Where is the function to check if a directory exists?


Go to solution Solved by mLipok,

Recommended Posts

Posted

I'm surprised I've never needed this before now but... how do you find out if a directory exists? 

  Reveal hidden contents
 
  • Solution
Posted

FileExist ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 4/7/2022 at 2:15 PM, mLipok said:

FileExist ?

Expand  

Right, right.... I forgot we can use that to check for directorys too...

Sorry about this, and thanks for the help and for your time. :)

  Reveal hidden contents
 
Posted

FileExists will return TRUE as well, when the tested name is a file, but not a directory.

 

$Dir2Ceck="C:\temp"
if FileExists($Dir2Ceck) Then
    if StringInStr(FileGetAttrib($Dir2Ceck),"D") Then ; Attribute "D" indicates this is a DIR
        ConsoleWrite("Directory " & $Dir2Ceck & " exists" & @CRLF)
    Else
        ConsoleWrite("Path exists, but isn't a directory (a file, propably): " & $Dir2Ceck & @CRLF)
    EndIf
Else
    ConsoleWrite("Path not found: " & $Dir2Ceck & @CRLF)
EndIf

 

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

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
  • Recently Browsing   0 members

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