Search code examples
fileactionscript-3air

Create folder in explicit directory AIR


Like the title says I want to create a folder in a specific directory with Adobe Air. If I use static methods of File like File.userDirectory works fine but I need to give the choice to select the directory. I am trying this:

file.addEventListener(Event.SELECT, dirSelected); 
file.browseForDirectory("Select a directory"); 

function dirSelected(e:Event):void { 
            trace(file.nativePath); 
            file.resolvePath("new_folder");
            file.createDirectory();
    }

Nothing happens


Solution

  • "resolvePath: Creates a new File object with a path relative to this File object's path, based on the path parameter (a string)."

    So:

    var newDir:File = file.resolvePath("new_folder");
    newDir.createDirectory();