存储/保存XML在AIR本地资源文件夹 [英] Storing/Saving XML in local asset folder in AIR

查看:225
本文介绍了存储/保存XML在AIR本地资源文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AIR一般好像是存储在安装了该应用程序所在的路径的XML文件。 我生成XML我想保存/存储的AIR应用程序的本地资产文件夹中的XML文件。

AIR in general seems to be storing the xml file in the path where the app is installed. I am generating an xml and I want to save/store a xml file in local asset folder of AIR application.

在这样做的任何想法。

推荐答案

File类有一些静态变量指向本地目录:

The File class has some static variables that point to local directories:

从文档:

      
  • File.applicationStorageDirectory - 存储目录中唯一的每个安装AIR应用程序
  •   
  • File.applicationDirectory - 应用程序的安装位置的只读目录(其中包括所有已安装的资源)
  •   
  • File.desktopDirectory - 用户的桌面目录
  •   
  • File.documentsDirectory - 用户的文档目录
  •   
  • File.userDirectory - 用户目录
  •   
  • File.applicationStorageDirectory — a storage directory unique to each installed AIR application
  • File.applicationDirectory — the read-only directory where the application is installed (along with any installed assets)
  • File.desktopDirectory — the user's desktop directory
  • File.documentsDirectory — the user's documents directory
  • File.userDirectory — the user directory

创建一个指向该文件

通常你要存储的文件像这些在File.applicationStorageDirectory。 因此,要创建文件做的:

Usually you'll want to store files like these in File.applicationStorageDirectory. So to create the file do:

File.applicationStorageDirectory.resolvePath("my-config.xml");

另外,也可以让用户选择在什么地方使用<一个存储文件href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html#browseForSave%28%29"相对=nofollow>文件#browseForSave(),它会显示一个原生保存窗口中选择的位置。

Alternatively, you can let the user choose where to store the file by using File#browseForSave(), which will display a native 'save' window to choose the location.

编写内容

在写模式下,文件打开FileStream,写一个XML字符串的文件。

Open a FileStream for the File in 'write' mode and write an XML string to the file.

var fs:FileStream = new FileStream();
fs.open(file, FileMode.WRITE);
fs.writeUTF(myXmlContent);
fs.close();

这篇关于存储/保存XML在AIR本地资源文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆