Get list of all files in a directory?

How can I get a list of all files in a given local directory (standalone player)?

For instance, I have a "characters" folder that goes inside my app directory, and I would like to be able to get a list of all XML (or whatever) files in that folder at runtime to parse through.

Preferably in Javascript but C# is fine.

Use DirectoryInfo:

import System.IO;
...
var info = new DirectoryInfo(path);
var fileInfo = info.GetFiles();
for (file in fileInfo) print (file);

In C# you can do it with:

using System.IO;
DirectoryInfo dir = new DirectoryInfo(myPath);
FileInfo[] info = dir.GetFiles("*.*");
foreach (FileInfo f in info) 
{ ... }

I found Some Simple Code For this,
Click here

ANSWER UPDAtE 2015 ERICS ANSWER IS NOT CURRENT SYNTAX>…





YES THIS IS CURRENT ANSWER YOU SAW THAT HAHA

function Start () {
GetFiles();

// var filePaths : String[] = Directory.GetFiles(info);
// for (file in filePaths) print (file);

}

or

function GetFiles(){

var info :String = Application.dataPath + "/AudioWave/";
 var fileInfo =Directory.GetFiles(info);
 for (file in fileInfo) print (file);

  }

System.IO.Path.GetFileName(fullPath)  

to get the name of only the file from string… fullpath string.

to get the files by type do this i.e. text

var fileInfo =Directory.GetFiles(info,“*.txt”);