Imports System.IO Module AttribViewer ' Custom function similar to DECLARE FUNCTION Attrib% (FileSpec$) Function Attrib(fileSpec As String) As Integer If Not File.Exists(fileSpec) And Not Directory.Exists(fileSpec) Then Console.WriteLine("File or directory does not exist.") Return -1 End If Dim attributes As FileAttributes = File.GetAttributes(fileSpec) Dim result As Integer = 0 ' Map attributes to bit flags like the original specification If (attributes And FileAttributes.ReadOnly) = FileAttributes.ReadOnly Then result = result Or (1 << 0) ' Bit 0: Read-only End If If (attributes And FileAttributes.Hidden) = FileAttributes.Hidden Then result = result Or (1 << 1) ' Bit 1: Hidden End If If (attributes And FileAttributes.System) = FileAttributes.System Then result = result Or (1 << 2) ' Bit 2: System End If ' Bit 3: Volume label – Not supported in .NET, skip or leave unset If (attributes And FileAttributes.Directory) = FileAttributes.Directory Then result = result Or (1 << 4) ' Bit 4: Subdirectory End If If (attributes And FileAttributes.Archive) = FileAttributes.Archive Then result = result Or (1 << 5) ' Bit 5: Archive End If ' Bit 6: Not used ' Bit 7: Shareable – Novell networks only, not supported here Return result End Function Public Sub MainAttrib() Console.Write("Enter file or directory path: ") Dim filePath As String = Console.ReadLine() filePath = "C:\Test\test\main.html" Dim attrValue As Integer = Attrib(filePath) If attrValue >= 0 Then Console.WriteLine($"Attribute value: {attrValue} (Binary: {Convert.ToString(attrValue, 2).PadLeft(8, "0"c)})") End If Console.WriteLine("Press any key to exit.") Console.ReadKey() End Sub End Module
Download 'Attribute Viewer':
📥 Download attribviewer.vb