I use the following command to search all .xaml files in the directory including all subdirectories:
However, the code should avoid searching in the subdirectory called “Logs”. Or, alternatively, the code should skip all of the .xaml files that contain the word “MergedFile”. How can I implement either of these two exceptions?
Directory. GetFiles(“D:\Samplek”, “*.xaml”, SearchOption.AllDirectories).Where(function(s) NOT s.Contains(“MergedFile”))
use it in For each with type argument String.
SearchOption in GetFiles has only two values- TopDirectoryOnly and AllDirectories. So, no option here to exclude files.
But you can achieve this using LINQ query -
Directory.GetFiles(@"C:\Users\Karthik\Desktop\uipath\ReFrameWork-master\", "*.xaml", SearchOption.AllDirectories)
.Where(s => !(s.Contains("MergeData") || s.Contains("\\Log\\")))
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.