Anyone have the correct syntax to remove a directory…?

Post Reply
BuckXUK
Newbie
Posts: 19
Joined: Thu Mar 01, 2012 8:43 pm

Anyone have the correct syntax to remove a directory…?

Post by BuckXUK »

Hello all



I'm trying to find the right syntax to remove a directory using the rmdir option in the Utility>Dir class. I've tried every possible syntax variation I can think of and cannot get this option to work.



This is the error I receive:



Error in line 76 of script : TypeError. 'rmdir' undefined or not a function



I've tried:



Dir.rmdir(variableName);



rmdir(variableName);



variableName.rmdir();



Dir.variableName.rmdir();



Can anyone point me in the right direction on this?



Thanks.



William Buckingham
Regards,

William Buckingham
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Anyone have the correct syntax to remove a directory…?

Post by dkelly »

Try



var theDir = new Dir(variableName);

theDir.rmdir();



or



var theDir = new Dir(variableName);

theDir.rmdirs();





The 2nd version will delete subdirectories (and files) if present.



Neither rmdir(dirName) and rmdirs(dirName) are NOT static members for some reason. I've reported the problem previously to Enfocus.
BuckXUK
Newbie
Posts: 19
Joined: Thu Mar 01, 2012 8:43 pm

Anyone have the correct syntax to remove a directory…?

Post by BuckXUK »

Hi Dwight



Thanks for the response and I can report your 2nd option works.



I had declared the variableName in the exact same way as your syntax outside the if/else block that does the removal, but setting it inside the conditional block with your syntax sorted it out.



Thanks again.



William Buckingham


Regards,

William Buckingham
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Anyone have the correct syntax to remove a directory…?

Post by dkelly »

Buck, my guess why rmdir() didn't work is there was a file in the directory, possibly hidden.
Post Reply