Maxscript Delete Directory / Folder Solution

Didn’t catch any other thread asking about this so I thought I would post up an easy way to delete folders using dotnet in Maxscript.
(Maxscript doesn’t have a built in way to delete folders)

filePath = "C:\Documents\...\Folder" --define a directory/folder path, or you could just put the path directly into the line below
(dotNetClass "System.IO.Directory").Delete(folderPath) --this line deletes the directory/folder

I’m using it to delete empty folders. I have not tested whether this works with folders that still have files in them.

Let me know if anybody has any problems with it, I would be good to understand where it works and where it doesn’t.

This should also work, you can find it in the Maxscript help file.

str = "rmDir C:\\doscmdtest\\"
hiddendoscommand str startpath:"$max" exitCode:&exitcode