AIR 中的 File 对象 所访问的文件夹位置

AIR 中的 File 对象 所访问的文件夹位置

Link

AIR 中的 File 对象 所访问的文件夹位置

AIR 中的 File 对象 所访问的文件夹位置

AIR 中的 File 对象 所访问的文件夹位置

AIR 中的 File 对象 所访问的文件夹位置

关于File.cacheDirectory的一点说明

According to the Apple guidelines, data that can be downloaded again or regenerated shall be stored in the <APPLICATION_HOME>/Library/Caches directory.

So, with AIR 3.6, a new static property, File.cacheDirectory has been introduced, which points to this directory. Files stored in this directory are not backed up on the iCloud.

Examples of files you should put in the Caches directory include database cache files and downloadable content, such as that used by magazine, newspaper, and map applications.

On Mac OSX and Android, File.cacheDirectory points to the Caches directory ( <APPLICATION_HOME>/Library/Caches on Mac and <APPLICATION_HOME>/caches directory on Android). While on Windows, it points to the parent directory being used by File.createTempDirectory.

var myCacheFile: File = File.cacheDirectory.resolvePath("cacheFile.txt");

There can be cases when a file or directory is required to be stored in a directory other than <APPLICATION_HOME>/Library/Caches directory, but still not required to be backed up on the iCloud, eg. files stored in the application storage directory. To address this issue, another property, preventBackup has been added to the File API. The default value of this property is false on all platforms and can be set to true only on iOS. When the property is set to true for a File object on iOS, the file/directory corresponding to that File object is not backed up on the iCloud. If the File object points to a directory on iOS, all files in that directory are not backed up (irrespective of the values of preventBackup for individual files/sub-directories of that directory). This property works on iOS 5.1 devices and later and does not work on the iOS Simulator. Files stored in APP_HOME/tmp/ or APP_HOME/Library/Caches directory are not backed up, irrespective of the value set for this property. On querying the value of preventBackup for a particular File object, the last set value of preventBackup or false (the default value) will be returned on iOS and all other platforms will continue to return false, even if explicitly set to true.

var file: File = File.applicationStorageDirectory.resolvePath("abc.txt");
file.preventBackup = true;

The above properties will only work for application descriptor namespace 3.6 (or greater) and SWF version greater than 19.

上一篇:回顾JDBC


下一篇:ASCII码对应表chr(9)、chr(10)、chr(13)、chr(32)、chr(34)、chr(39)