Some .net/mono frameworks do not support the 3 argument GetDirectories method. The code below provides a simple replacement.
/// <summary>
/// Builds an array of folders & sub folders.
/// </summary>
/// <param name="path">The path to search.</param>
/// <param name="pattern">The search string to match against the names of files in path. The parameter cannot end in two periods
/// ("..") or contain two periods ("..") followed by System.IO.Path.DirectorySeparatorChar or System.IO.Path.AltDirectorySeparatorChar,
/// nor can it contain any of the characters in System.IO.Path.InvalidPathChars.
///</param>
/// <param name="searchOptions">One of the System.IO.SearchOption values that specifies whether the search operation should include
/// all subdirectories or only the current directory.
///</param>
/// <returns>A String array of directories that match the search pattern.</returns>
public static string[] GetDirectories(string path, string pattern, SearchOption searchOptions)
{
// check if searching for all directories
if (searchOptions == SearchOption.AllDirectories)
{
// add start paths to list
var list = Directory.GetDirectories(path, pattern);
var index = 0;
var count = list.Length;
// process list and add folders to end of list
while (index < count)
{
var directories = Directory.GetDirectories(list[index++], pattern);
if (directories.Length > 0)
{
// check if we need more space to store the directories
if (count + directories.Length > list.Length - 1)
{
Array.Resize(ref list, list.Length + directories.Length + 1000);
}
// add directories to end of the list
foreach (var directory in directories)
{
list[count++] = directory;
}
}
// trim unused index from end of the array
if (list.Length > count)
{
Array.Resize(ref list, count);
}
}
return list;
}
// just return initial list of folder with no sub folders
return Directory.GetDirectories(path, pattern);
}