How can I list all scripts at a path.

Hi there,

I want to list the scripts at a asset path, recursively, in c#. I also want to be able to grab the file in code and then be able to add it to game objects and do whatever.

Basically do what the Project Tree does.

How can I do this? should I use .Net libraries to achieve this?

I ended up doing something like this (copy pasted from different places, so it doesnt add up, but you should get the general idea).

List<DirectoryInfo> directoryInfos = new List<DirectoryInfo>(dirInfo.GetDirectories("*", SearchOption.TopDirectoryOnly));

List<FileInfo> fileInfos = new List<FileInfo>(directoryInfo.GetFiles(fileMask, SearchOption.TopDirectoryOnly));

UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(filePath.Remove(0, path), type);

MonoScript script = obj as MonoScript;
if (script)
     Type scriptType = script.GetClass();
     if (scriptType.IsSubclassOf(typeof(MonoBehaviour)))
          UnityEngine.Object obj = UnityEngine.Object.FindObjectOfType(scriptType);
          MonoBehaviour mono = obj as MonoBehaviour;