# List files in a directory with AS

**URL:** <https://forum.kirupa.com/t/list-files-in-a-directory-with-as/151863>\
**Category:** flash\
**Created:** [June 18, 2005, 9:34pm UTC](https://forum.kirupa.com/t/list-files-in-a-directory-with-as/151863 "2005-06-18T21:34:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![simobk](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@simobk](https://forum.kirupa.com/u/simobk)\
**Post date:** [June 18, 2005, 9:34pm UTC](https://forum.kirupa.com/t/list-files-in-a-directory-with-as/151863/1 "2005-06-18T21:34:40Z")

</div>

Hi all,

Just wondering if this could be done directly in Flash… Basically, what I want is a function that just opens a directory, check all the files that are in it, and place their filename into an array…

I know I can do this with PHP, then send results to flash, but I was wondering if this could be done directly in Flash…

Here is the code I want in PHP, my question is : Could that be “translated” to AS?

```php
function listFiles($target) 
{ 
	$opnDir = opendir($target); 
	$fileArray = array(); 
	while ( ( $file = readdir($opnDir) ) !== false ) 
	{ 
		if ( ($file != ".") && ($file != "..") ) 
		{ 
			$fileArray[] = $file; 
		} 
	} 
	closedir($opnDir); 
}

```

Thanks,  
Simo
