get resource file count in unity code example

Example 1: unity how to tell how many objets are in a folder

void Start()
    {
        //I needed to get a count of my all level prefabs from my
        //Resources folder so I hashed together this frankenstein code:

        //Get the path of the Levels folder from Resources
        string AssetsFolderPath = Application.dataPath;
        string levelFolder = AssetsFolderPath + "/Resources/Levels";

        Debug.Log("dataPath : " + levelFolder);

        //////////////////////

        //DirectoryInfo needs "using System.IO"
        DirectoryInfo dir = new DirectoryInfo(levelFolder);
        FileInfo[] info = dir.GetFiles("*.prefab");
        int fileCount = info.Length;

        Debug.Log("Level Count: " + fileCount);

        //Clear array to save space, needs "using System"
        Array.Clear(info, 0, info.Length);
    }

Example 2: unity3d get all names of resources

using System.IO; using System.Collections.Generic; private List<string> PlayersInFolder; void Start () {      PlayersInFolder = new List<string> ();      string myPath = "Assets/Resources/";      DirectoryInfo dir = new DirectoryInfo (myPath);      FileInfo[] info = dir.GetFiles ("*.*");      foreach (FileInfo f in info) {     if (f.Extension == ".FBX" || f.Extension ==      ".prefab") {     string tempName = f.Name;     string extension = f.Extension;     string strippedName = tempName.Replace (extension,  "");                                                                 PlayersInFolder.Add (strippedName);      } }