cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Determine if a Windows folder exists...

Visitor

Determine if a Windows folder exists...


So I have code that will create a Windows folder, but prior to making this folder I would like to test to see if it exists and ifit does exist do some kind of processing to the data in the folder (prompt user before removing data).


There currently is no command in SA that will allow me to determine if the folder exists in one short statement. I am finding that I need to issue some command and catch an error so I know the folder does not exist.


I have a few ways of attempting to complete this, but I am interested in how others accomplished this task and what process they may have used to do so. It is hard for me to believe I am the first to want to complete such a task...


Any help is appreciated!



Regards,


Brian Noll


Project Manager, Design Proces Automation


Johnson Controls Inc.


Wildfire 4.0 (M220), Windchill (M040), SmartAssembly 5.0 (M110)


2 REPLIES 2
Highlighted

RE: Determine if a Windows folder exists...

I just tried both the READ_DIRECTORY and READ_SUBDIRECTORIES and they do not appear to error out when unable to find a directory. Instead, p


READ_SUBDIRECTORIES "myPath" mySubDirArray


FOR mySubDir REF ARRAY mySubDirArray


IF mySubDir == checkDir


! sub-directory exists, run your other code here


! BREAK


END_IF


END_FOR


--Geoff

Highlighted

Determine if a Windows folder exists...

Geoff -

Yep, this works well. Thank you for the response.

Brian
Announcements