Rella
Rella

Reputation: 66965

How to get folder size in Adobe Air?

How to get folder size in Adobe Air?

Upvotes: 1

Views: 1284

Answers (3)

Maxim Firsoff
Maxim Firsoff

Reputation: 2296

my implementation is:

public static function getFileSize(file:File):Number{ var result:Number = 0; if(file == null || file.exists == false) { return 0; } if(file.isDirectory){ var files:Array = file.getDirectoryListing(); for each (var f:File in files) { if(f.isDirectory){ result += getFileSize(f); }else{ result += f.size; } } }else{ return file.size; } return result; }

Upvotes: 1

Juan Delgado
Juan Delgado

Reputation: 2030

Should be fairly simple using File.size. Just in case is confusing, folders in AIR are represented using the File class, which extends FileReference, thus the link to the FileReference documentation.

Upvotes: 1

Robert Harvey
Robert Harvey

Reputation: 180878

Recursive folder listings and contents processing
http://cookbooks.adobe.com/post_Recursive_folder_listings_and_contents_processing-9410.html

...has sufficient sample code in it to get you started.

Upvotes: 1

Related Questions