LINQ filtering doesn't work

Steven Young 261 Reputation points
2022-03-20T12:56:43.387+00:00

I want to exclude the system directory from the IEnumerable, the file properties like the image below
184857-1.png

But the code below will exclude all nodes include "Directory" or "System" , i want to exclude the nodes include "Directory" and "System". How to fix the code below?

nodes.Where(Function(n) n.Attributes And (n.Attributes.ToString.IndexOf("Directory") < 0 And n.Attributes.ToString.IndexOf("System") < 0))

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,698 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Steven Young 261 Reputation points
    2022-03-20T13:24:56.567+00:00

    I known how to do it.

    nodes.Where(Function(n) n.Attributes And not (n.Attributes.ToString.IndexOf("Directory") > 0 And n.Attributes.ToString.IndexOf("System") > 0))

    0 comments No comments