加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex获取文件夹下的所有文件名

发布时间:2020-12-15 04:40:58 所属栏目:百科 来源:网络整理
导读:!--?注释掉的代码是原创,引用自http://bbs.9ria.com/thread-85208-1-1.html ,没有注释的代码是自己改写的-- ? !-- ??xml version="1.0" encoding="utf-8"? ?s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" ?xmlns:s="library://ns.adobe.

<!--?注释掉的代码是原创,引用自http://bbs.9ria.com/thread-85208-1-1.html ,没有注释的代码是自己改写的-->

?

<!--
?<?xml version="1.0" encoding="utf-8"?>
?<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
?xmlns:s="library://ns.adobe.com/flex/spark"
?xmlns:mx="library://ns.adobe.com/flex/mx"
?title="AIR遍历文件夹" creationComplete="windowedapplication1_creationCompleteHandler(event)">
?<fx:Script>
?<![CDATA[
?import mx.events.FlexEvent;
?
?private var file:File;
?protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
?{
?this.removeEventListener(FlexEvent.CREATION_COMPLETE,windowedapplication1_creationCompleteHandler);
?file = new File();
?file.addEventListener(Event.SELECT,file_selectHandler);
?}
?//File的选择事件
?protected function file_selectHandler(event:Event):void
?{
?var arr:Array = file.getDirectoryListing();
?dg.dataProvider = arr;
?this.status = file.nativePath;
?}
?//单击按钮
?protected function btn_clickHandler(event:MouseEvent):void
?{
?file.browseForDirectory("请选择一个文件夹");
?}
?
?]]>
?</fx:Script>
?<fx:Declarations>
?
?</fx:Declarations>
?<s:Button id="btn" label="打开"? click="btn_clickHandler(event)"/>
?<mx:DataGrid id="dg" width="100%" height="100%" y="30">
??<mx:columns>
???<mx:DataGridColumn headerText="文件名" dataField="name"/>
???<mx:DataGridColumn headerText="创建日期" dataField="creationDate"/>
???<mx:DataGridColumn headerText="修改日期" dataField="modificationDate"/>
???<mx:DataGridColumn headerText="文件夹" dataField="isDirectory"/>
???<mx:DataGridColumn headerText="大小" dataField="size"/>
???<mx:DataGridColumn headerText="类型" dataField="type"/>
??</mx:columns>
?</mx:DataGrid>
?</s:WindowedApplication>
-->

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" ??????? xmlns:s="library://ns.adobe.com/flex/spark" ??????? xmlns:mx="library://ns.adobe.com/flex/mx" ??????? title="AIR遍历文件夹" > ?<fx:Script> ??<![CDATA[ ???import mx.controls.Alert; ???//import mx.events.FlexEvent; ???private var file:File; ???//File的选择事件 ???protected function file_selectHandler(event:Event):void ???{ ????var arr:Array = file.getDirectoryListing(); ????for(var i:int = 0 ; i < arr.length ; i ++){ ?????Alert.show(arr[i].name) ; ????} ???} ???//单击按钮 ???protected function btn_clickHandler(event:MouseEvent):void ???{ ????file = new File(); ????file.addEventListener(Event.SELECT,file_selectHandler); ????file.browseForDirectory("请选择一个文件夹"); ???} ??? ??]]> ?</fx:Script> ?<fx:Declarations> ??<!-- 将非可视元素(例如服务、值对象)放在此处 --> ?</fx:Declarations> ?<s:Button id="btn" label="打开"? click="btn_clickHandler(event)"/> ?<mx:TabNavigator> ?? ?</mx:TabNavigator> </s:WindowedApplication>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读