Skip to main content
1-Visitor
September 10, 2014
Question

Determine if a Windows folder exists...

  • September 10, 2014
  • 2 replies
  • 1484 views

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)



This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.

2 replies

1-Visitor
September 10, 2014

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

bnoll1-VisitorAuthor
1-Visitor
September 11, 2014
Geoff -

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

Brian