static public FileInfo FindFile(string s, DirectoryInfo SrcDir = null) { if (SrcDir == null) { SrcDir = new DirectoryInfo(Environment.CurrentDirectory); } if (SrcDir.Exists) { var file = SrcDir.GetFiles().Where(f => f.Name == s).FirstOrDefault(); if (file != null) { return(file); } var lsDir = SrcDir.GetDirectories(); foreach (var temp in lsDir) { file = FindFile(s, temp); if (file != null) { return(file); } } } return(null); }
static public DirectoryInfo FindDir(string s, DirectoryInfo SrcDir = null) { if (SrcDir == null) { SrcDir = new DirectoryInfo(Environment.CurrentDirectory); } if (SrcDir.Exists) { var lsDir = SrcDir.GetDirectories(); var dir = lsDir.Where(f => f.Name == s).FirstOrDefault(); if (dir != null) { return(dir); } foreach (var temp in lsDir) { dir = FindDir(s, temp); if (dir != null) { return(dir); } } } return(null); }