AIR 文件存储路径三种选择

AIR 文件存储路径三种选择
1.File.desktopDirectory

路径参数:C:\Documents and Settings\当前用户名\桌面\

file = File.desktopDirectory.resolvePath(“HelloWorld.txt”);
var stream:FileStream = new FileStream()
stream.open(file, FileMode.WRITE);
var str:String = “Congratulations on AIR Save Path “;
stream.writeUTFBytes(str);
stream.close();

2.File.applicationStorageDirectory

路径参数:C:\Documents and Settings\当前用户名\Application Data\应用程序项目名\Local Store\

var file:File = File.applicationStorageDirectory.resolvePath(“HelloWorld.txt”);
var stream:FileStream = new FileStream()
stream.open(file, FileMode.WRITE);
var str:String = “Congratulations on AIR Save Path”;
stream.writeUTFBytes(str);
stream.close();

3.File.documentsDirectory
路径参数:C:\Documents and Settings\当前用户名\My Documents\

var file:File = File.documentsDirectory.resolvePath(“HelloWorld.txt”);
var stream:FileStream = new FileStream()
stream.open(file, FileMode.WRITE);
var str:String = “Congratulations on AIR Save Path”;
stream.writeUTFBytes(str);
stream.close();

AIR保存文件

var file:File = new File(“C://abc.txt”)

var fs:FileStream = new FileStream()

fs.open(file,FileMode.WRITE)

fs.position = 0

fs.writeUTFBytes(“http://https://https://cfzy.site”)

fs.close()

这样就会在C盘生成一个内容为”http://https://https://cfzy.site”的abc.txt文件..