actionscript3.0对本地文件的读写

import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;

import flash.utils.ByteArray;

public static function writeAppFile(fileName:String, datas:ByteArray):void{
   var file:File = new File(File.applicationDirectory.resolvePath(fileName).nativePath);
   var fs:FileStream = new FileStream();
   fs.open(file,FileMode.WRITE);
   fs.position = 0;
   fs.writeBytes(datas);
   fs.close();
  }
  public static function readAppFile(fileName:String):void{
   var file:File = new File(File.applicationDirectory.resolvePath(fileName).nativePath);
   var fs:FileStream = new FileStream();
   fs.open(file,FileMode.READ);
   fs.position = 0;
   fs.readBytes(data);
   fs.close();
  }

PS:初写文章,文笔生涩之处,各位请见谅,若有疑问或者交流的,可加本人YY号:301558660

转载请注明出处:山水间博客,http://blog.csdn.net/linyanwen99/article/details/7543414

你可能感兴趣的:(山水间文集)