Cant use .NET classes

Im trying to make a file explorer based on some scripts i got in unity forums but im getting the following error in my script.

BCE0019: ‘GetFiles’ is not a member of ‘System.IO.DirectoryInfo’.

My Script:

#pragma strict

import System.Collections.Generic;
import System.IO;

var path : String = "./";
var fileTypes : String[] = ["ogg", "wav"];

var files : FileInfo[];
var Source : AudioSource;
var audioclips : List.<AudioClip> = new List.<AudioClip>();

function Start () {
 if(Application.isEditor) {
 	path = "Assets/";
 	}
}

function Update () {

}

function ObtenerDatosDir() {
	var info : System.IO.DirectoryInfo = new System.IO.DirectoryInfo(path);
	files = info.GetFiles();
}

Any idea why i cant make it work?

I would check whether your build settings target platform (from what I know some .NET classes cannot be used in certain builds). [Try standalone].

Also, try using the full .NET 2.0 API by navigating to Project Settings → Player → Other Settings → API compatibility level (if it doesn’t work revert it because this will unnecessarily increase build size).

I’ve having a similar issue but the above didn’t work for me. Hopefully it does for you (based on what I searched).