Last active
July 4, 2023 04:31
-
-
Save alaawahbah/3c66e2f78340eb925b7d2182e9800c7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
// var asd = Directory.GetDirectories(@"D:\MyWork", "*.*", SearchOption.AllDirectories); | |
// | |
// var asdad1 = asd.Where(t =>t.EndsWith("node_modules") && (t.IndexOf("node_modules")==t.LastIndexOf("node_modules") && t.IndexOf("node_modules")!=-1)).ToList(); | |
// asdad1.Dump(); | |
GetRootDirectoryByName(@"D:\MyWork","node_modules").Dump(); | |
GetAllSubDirectory(@"D:\MyWork").Dump(); | |
} | |
List<string> GetRootDirectoryByName(string pathToSearch,string directoryName){ | |
var dirs = Directory.GetDirectories(pathToSearch, "*.*", SearchOption.AllDirectories); | |
return dirs.Where(t =>t.EndsWith(directoryName) && (t.IndexOf(directoryName)==t.LastIndexOf(directoryName) && t.IndexOf(directoryName)!=-1)).ToList(); | |
} | |
List<string> GetAllSubDirectory(string path){ | |
var dirs = Directory.GetDirectories(path, "*.*", SearchOption.AllDirectories); | |
return dirs.ToList(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment