LINQ filtering doesn't work

Steven Young 261 Reputation points

I want to exclude the system directory from the IEnumerable, the file properties like the image below

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

    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