How to use the FileSystem in AIR to find the users directory folders
Mar1
I was messing around last night with AIR and I stumbled apon this:
- start an AIR app in flash cs3
- add a list component
- name it dir_list
- drop the code below in the actions panel
- And Viola!
- PS – PC people, I put a test to see if My Documents in in that Directory.
[as]
import flash.filesystem.*;
var userDirFiles:Array = File.userDirectory.getDirectoryListing();
for (var i:uint = 0; i < userDirFiles.length; i++) {
if (userDirFiles[i].isDirectory) {
//this.display_txt.text = String(userDirFiles[i].nativePath);
dir_list.addItem({label:userDirFiles[i].nativePath })
var tmpString:String = userDirFiles[i].nativePath;
if(tmpString.search(/My Documents/) != -1)
{
dir_list.addItem({label:”working”});
break;
}
}
} [/as]
