AssetDatabase.CreateFolder not defined?

For some reason when I try to use the function AssetDatabase.CreateFolder(string, string) my code will not compile. This is really weird considering this is in the same editor script where I was able to use AssetDatabase.CreateAsset without any problems.

The exact error I get is:

Error CS0117: 'UnityEditor.AssetDatabase' does not contain a definition for 'CreateFolder' (CS0117)

This works perfectly for me:

//javascript
@MenuItem ("MyMenu/Do Something")
static function DoSomething () {

    var myGuid : String = AssetDatabase.CreateFolder("Assets", "My Folder");
    var newFolderPath = AssetDatabase.GUIDToAssetPath(myGuid);
    
    Debug.Log ("got :" + newFolderPath);
}

I just whacked it into a javascript file in Assets/Editor.

However, if you look at:

http://unity3d.com/support/documentation/ScriptReference/40_history.html

You’ll see that AssetDatabase.CreateFolder was added at Unity 3.4, so there is no chance at all that this will work in your 3.3 project. When working with older versions of Unity is is always best to consult the documentation that shipped with the version you use. The content we host online is always for the latest version. I’ll close your bug report as “By Design”.

I’ll probably just submit a bug about this. As far as I can tell, using the System version seems to work for me, so I recommend using

System.IO.Directory.CreateDirectory(string)

as a substitute.