How to check the Sub Dir's
<p>Am using M.Babcock code get the file list based on the "pattern" of the file name but the code below does the job but its not lookin the files in sub directories. Any help how to look the file patterns in Sub Dir's also</p>

<p>I know if use the below code will do the job</p>

<pre><code>DirectoryInfo[] DI = new DirectoryInfo(rootdir).GetDirectories("*.*", SearchOption.AllDirectories ) ;
</code></pre>

<p>But i couldn't understand how can i change his code to look the files in sub dir's also</p>

<p>M.Babcock code</p>

<pre><code>var getfiles = new fileshare.Program();
string realname = "*main*";
string Location = "SVR01";
var fileList = getFiles.GetFileList(realname, Location);
var anymatch = fileList.Any();

if (anymatch) // Or possibly `if (fileList.Any())` if anymatch isn't 
              // really used anywhere else
    baseMeta();

foreach (var file in getfiles.GetFileList(realname,Location))
    getfiles.copytolocal(file.FullName);
 switch (Location)
    {
        case "SVR01":
            directory = @"\\SVR01\Dev";
        break;

        case "SVR02":
            directory = @"\\SVR02\Dev";
        break;

        case "SVR03":
            directory = @"\\SVR03\Prod");
        break;

        default: 
            throw new ArgumentOutOfRangeException();

    }

    DirectoryInfo di = null;
    try
    {
        di = new DirectoryInfo(directory);
    }
    catch(Exception ex)
    {
        Console.WriteLine(ex.Message);
        yield break;
    }

    foreach(var fi in di.EnumerateFiles(pattern))
        yield return fi;
}
</code></pre>

<p>Thanks in Advance</p>
