I have the following code snippet:
string root = Path.GetDirectoryName(Application.ExecutablePath); List<string> FullFileList = Directory.GetFiles(root, "*.*", SearchOption.AllDirectories).Where(name => { return !(name.EndsWith("dmp") || name.EndsWith("jpg")); }).ToList();
Now it works very well, however the file names with it are long. Is there a way I can take the path to the root? but still show all subfolders?
Root = C: \ Users \\ Desktop \ Test \
But the code will return all the way from C: while I would prefer if I pulled out the root bit right away. but keep the file structure after it.
e.g. C: \ Users \\ Desktop \ Test \ hello \ hello \ files.txt will return \ Hello \ hello \ files.txt
I know that I can just iterate over the generated list of files and delete it one at a time, I wonder if I can just filter it out is not easy.
source share