2019-11-7 zhulinan Flash
package { import flash.display.MovieClip; import flash.events.*; import flash.filesystem.*; import flash.net.*; public class Main extends MovieClip { public function Main() { addEventListener(Event.ADDED_TO_STAGE, addedHandle); } private function addedHandle(e:Event):void { removeEventListener(Event.ADDED_TO_STAGE, addedHandle); btn.addEventListener(MouseEvent.CLICK, btnClickHandle); } private function btnClickHandle(e:MouseEvent):void { //var file:File = File.applicationDirectory.resolvePath("/data/1/1.txt"); var file:File = new File(File.applicationDirectory.nativePath + "/data/1/1.txt"); txt.text = ""; if(!file.exists) { txt.appendText(file.url + "文件不存在!\r\n"); var dir:File = file.parent; if (!dir.exists) { txt.appendText(dir.url + "文件夹不存在!\r\n"); dir.createDirectory(); if (dir.exists) { txt.appendText(dir.url + "文件夹创建成功!\r\n"); } } } var fs:FileStream = new FileStream(); fs.open(file, FileMode.WRITE); fs.writeUTFBytes("hangge.com"); fs.close(); } } }