Get and Set attributes of a file
this is an easy code to get and set any file's attibutes (system, hidden, read-only,...) throught the vb function getatr and setattr
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
'*** Get and Set attributes of o file *********** '* * '************************************************ Public Function GetAttributes(OfThis As String) As String Dim Tmp As VbFileAttribute Tmp = GetAttr(OfThis) If Tmp >= vbAlias Then '64 GetAttributes = GetAttributes & " Alias" Tmp = Tmp - vbAlias End If If Tmp >= vbArchive Then ' 32 GetAttributes = GetAttributes & " Archive" Tmp = Tmp - vbArchive End If If Tmp >= vbDirectory Then '16 GetAttributes = GetAttributes & " directory" Tmp = Tmp - vbDirectory End If If Tmp >= vbVolume Then '8 GetAttributes = GetAttributes & " volume" Tmp = Tmp - vbVolume End If If Tmp >= vbSystem Then '4 GetAttributes = GetAttributes & " System" Tmp = Tmp - vbSystem End If If Tmp >= vbHidden Then '2 GetAttributes = GetAttributes & " Hidden" Tmp = Tmp - vbHidden End If If Tmp >= vbReadOnly Then '1 GetAttributes = GetAttributes & " Read Only" Tmp = Tmp - vbReadOnly End If If Tmp = vbNormal Then '0 GetAttributes = GetAttributes & " Normal" Tmp = Tmp - vbNormal End If End Function Public Function SetAttributes(OfThis As String, ByVal ToThis As VbFileAttribute) As Boolean SetAttributes = True On Error GoTo errh SetAttr OfThis, ToThis GoTo fin errh: SetAttributes = False Err.Clear Exit Function fin: SetAttributes = True End Function
Original Comments (3)
Recovered from Wayback Machine