Hi Rainer,
Presently, there is no such a function for testing the existence of a subfolder in Project Explorer. However, you can write a function by using Origin C to do this.
Steps are below:
1. Click the Code Builder button on the standard toolbar to open the Coder Builder.
2. New a C File and add the following code in it.
// this function used to delete and create the specified subfolder in the active folder
void delete_and_create_subfolder_in_acitve_folder(string strFolder)
{
Folder fld = Project.ActiveFolder(); // get active folder
// call delete_and_create_subfolder() function
delete_and_create_subfolder(strFolder, fld.GetPath());
}
// this function used to delete and create the specified subfolder in the root folder
void delete_and_create_subfolder(string strFolder, string strRootPath = "")
{
// trim white space
strFolder.TrimRight();
strFolder.TrimLeft();
Folder fld(strRootPath); // get root folder path
if(fld.IsValid()) // if root folder exist
{
foreach(Folder subfolder in fld.Subfolders) // loop all subfolders
{
// if subfolder exist
if(0 == subfolder.GetName().Compare(strFolder) )
{
// delete this subfolder
fld.RemoveSubFolder(subfolder.GetName());
}
else
{
if( subfolder.Subfolders.Count() > 0 ) // search subfolder's subfolder
{
delete_and_create_subfolder(strFolder, subfolder.GetPath());
}
}
}
fld.AddSubfolder(strFolder); // add a subfolder by the specified name
}
}
3. Click the Build button.
4. Return to Origin. If you want to delete then create a subfolder in the active folder, just type
delete_and_create_subfolder_in_acitve_folder("SubProj");
in command window.
We have submitted a tracker (tr#14817) to improve the exist() function, then you can use it to test the existence of a subfolder in Project Explorer.
Penn
OriginLab Technical Services