Module Module1 Sub Main() Dim file As String = "C:\Windows\System32\drivers\etc\hosts" Dim dir As String = "C:\Windows" Dim notExist As String = "C:\path\to" Console.WriteLine(file & ":" & GetAttr(file)) Console.WriteLine(dir & ":" & GetAttr(dir)) Console.WriteLine(notExist & ":" & GetAttr(notExist)) End Sub Function GetAttr(pathto As String) As String Dim result As String = "" Dim attr As System.IO.FileAttributes Try attr = System.IO.File.GetAttributes(pathto) If ((attr And System.IO.FileAttributes.Directory) = System.IO.FileAttributes.Directory) Then result = "Directory" ElseIf ((attr And System.IO.FileAttributes.Archive) = System.IO.FileAttributes.Archive) Then result = "Archive file" ElseIf ((attr And System.IO.FileAttributes.Normal) = System.IO.FileAttributes.Normal) Then result = "Normal file" Else result = "unknown" End If Catch ex As Exception result = "error" End Try Return result End Function End Module