Could you show me an example of how I test for these attributes? It seems
like the Attributes property has an enumeration containing Hidden and
System, but I am having trouble testing whether they are true for the
current DirectoryInfo. Thanks.
>> I am getting the list of subdirectories from a specified directory using
>> System.IO.Directory.GetDirectories(), and would like to get only
[quoted text clipped - 16 lines]
> --
> Tom Shelton
Tom Shelton - 17 Oct 2007 06:29 GMT
> Could you show me an example of how I test for these attributes? It seems
> like the Attributes property has an enumeration containing Hidden and
[quoted text clipped - 23 lines]
>
> - Show quoted text -
Nathan,
Those attributes are flag attributes - so a simple bitwise and will
tell you if they have the attribute:
Option Strict On
Option Explicit On
Imports System
Imports System.IO
Module Module1
Sub Main()
Dim rootInfo As DirectoryInfo = New DirectoryInfo("c:\")
For Each d As DirectoryInfo In rootInfo.GetDirectories()
If (d.Attributes And FileAttributes.System) <>
FileAttributes.System Then
Console.WriteLine(d.Name)
End If
Next
End Sub
End Module
HTH,
--
Tom Shelton