IsDirectoryPresent
Determines if the specified directory exists and optionally creates it.
Member of namespace
FileIOSyntax
bool IsDirectoryPresent (string directoryName, bool create, bool testExistence)
Parameters
- directoryName
- Type: string
- create
- Type: bool
- testExistence
- Type: bool
Parameters
- directoryName : The directory path to test. Smart parameters are allowed.
- create : Specifies if the directory should be created. True creates the directory, if it does not exist.
- testExistence : Determines if True should be returned if the directory exists or does not exist.
Returns
If testExistence is True, the action will return True if the directory exists or if the directory did not exist but was successfully created.If testExistence is False, the action will return True if the directory does not exist. This allows you to perform negative tests that will return true when a directory does not exist.
If an error occurs, the action will return False.
Level
All levels.Details
Checks for the existence of a directory. Depending on the input parameters, if the directory does not exist, the action creates the directory. The meaning of the return value can be changed using the testExistence parameter. This allows rules to continue if a directory exists or rules can continue if a directory does not exist.- Example
IsDirectoryPresent("c:\temp", true, true)This example creates the directory C:\temp, if it does not exist, and returns True if the directory exists or was created successfully.
IsDirectoryPresent("c:\temp", true, false)This example creates the directory C:\temp, if it does not exist, and returns False if the directory exists or was created successfully.