ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

IsNotHidden

Filters out directories that are hidden

Source

public static class DirectoryInfoExtensions
{
    public static bool IsNotHidden(this DirectoryInfo directoryInfo)
    {
        return (directoryInfo.Attributes & FileAttributes.Hidden) == 0;
    }
}

Example

var files = new DirectoryInfo(@"\\myserver\C$").GetDirectories().Where(x => x.IsNotHidden()).Select(x => x.Name).ToArray();

Author: Nitin Chaudhari

Submitted on: 3 feb. 2012

Language: C#

Type: System.IO.DirectoryInfo

Views: 4827