Listing files and directories possible.

Jul 12, 2010 at 7:03 PM
"Listing files and directories are not yet possible, it appears that dynamic handles the FolderObject.SubFolders & FolderObject.Files differently, Silverlight can not enumerate the collection whereas it works as expected in standard .NET." Here is the code for getting a list of files at a given path. public static string[] GetFiles(string path)//, string searchPattern, SearchOption searchOption) { DirectoryInfo di = new DirectoryInfo(fileSystemObject.GetFolder(path)); List<string> fileNames = new List<string>(); dynamic dir = fileSystemObject.GetFolder(path); foreach (var item in dir.Files) { fileNames.Add(item.Name); } return fileNames.ToArray(); } Following is the code for getting a list of Folders at a given path. public static string[] GetDirectories(string path)//, string searchPattern, SearchOption searchOption) { List<string> dirNames = new List<string>(); dynamic dir = fileSystemObject.GetFolder(path); foreach (var item in dir.SubFolders) { dirNames.Add(item.Name); } return dirNames.ToArray(); } Hopefully this helps someone.