public static string[] GetFileNames(string dir) { var names = new List<string>(); var files = Directory.GetFiles(dir); names.AddRange(files); var dirs = Directory.GetDirectories(dir); if (dirs.Length <= 0) { return names.ToArray(); } else { foreach (var tmp in dirs) names.AddRange(GetFileNames(tmp)); return names.ToArray(); } }