Adobe AIR provides great references to common locations on a user’s computer that map to the right place depending on the operating system.
- File.userDirectory — User’s home directory.
- File.desktopDirectory — User’s desktop.
- File.documentsDirectory — User’s documents.
- File.applicationDirectory — AIR application directory.
- File.applicationStorageDirectory — AIR application settings directory.
It’s missing one, however: File.downloadsDirectory. Here’s what would work:
/** * File.downloadsDirectory * * Returns the appropriate location to place downloaded files. * (falls back to the Desktop) */ public function get downloadsDirectory():File { var downloadsDirectory:File; downloadsDirectory = File.userDirectory.resolvePath('Downloads'); if (downloadsDirectory.isDirectory) return downloadsDirectory; downloadsDirectory = File.documentsDirectory.resolvePath('Downloads'); if (downloadsDirectory.isDirectory) return downloadsDirectory; return File.desktopDirectory; }