[AIR] 利用File获取应用程序根目录
import flash.filesystem.File; var file1:File = new File(File.applicationDirectory.resolvePath("data/未来生活由您来定义.xml").nativePath); trace(file1.nativePath);//获取未来生活由您来定义.xml的绝对地址 trace(File.applicationDirectory.nativePath);//获取应用程序根目录 var file:File=File.applicationDirectory; var _diskRootPath:String; _diskRootPath=file.nativePath+"/"; var pattern:RegExp = /\\/g;//正则表达式,将“\”字符换成“/”字符 _diskRootPath = _diskRootPath.replace(pattern, "/"); trace(_diskRootPath);
------------------------------------------------------------------
Always put yourself in the other's shoes.If you feel that it hurts you,it probably hurts others,too.------------------------------------------------------------------