---
title: "air遍历目录里的文件"
author: "Fis"
date: "2015-02-12T15:52:32Z"
tags: []
categories: ["移动开发"]
slug: "air"
draft: false
lastmod: "2015-02-12T15:52:17Z"
id: 2185411
url: "https://fis.iteye.com/blog/2185411"
---

air开发移动应用时，用于遍历一个目录里的所有文件：

var file:File = File.applicationDirectory.resolvePath("xxx");
var fileList:Array = file.getDirectoryListing();
for each(var f:* in fileList) {
    this.checkPath(f);
}

_fileList = ;
private function checkPath(file:File):void {
    if (file.isDirectory) {
        var list:Array = file.getDirectoryListing();
        for each(var f:* in list) {
            this.checkPath(f);
        }
    }else {
        _fileList.push(file);
    }
}