GetAttr

Reads attributes of a file using FSO.
Return will be a string of RHSA (Read-only, Hidden, System, Archive) or any of these for selected file.
Uses included ConvertAttrBinary function to convert binary into array.
Can pass either MapPathed or UnMapPathed

CodeFunctionName
What is this?

Public

Tested

Original Work
Private Function GetAttr(FullFile_MapPathed, FullFile_UnMapPathed)
If FullFile_MapPathed > "" And FullFile_UnMapPathed = "" Then
ElseIf FullFile_MapPathed = "" And FullFile_UnMapPathed > "" Then
FullFile_MapPathed= Server.MapPath(FullFile_UnMapPathed)
End If
Dim lvAttributes, lsResult
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFile(FullFile_MapPathed)
AttributeValue = File.Attributes
lvAttributes = Split(ConvertAttrBinary(AttributeValue, 1, 7, ","), ",")
If lvAttributes(0) = 1 Then lsResult = "R" 'ReadOnly?
If lvAttributes(1) = 1 Then lsResult = lsResult & "H" 'Hidden?
If lvAttributes(2) = 1 Then lsResult = lsResult & "S" 'System?
If lvAttributes(5) = 1 Then lsResult = lsResult & "A" 'Archive?
GetAttr = lsResult
End Function
Private Function ConvertAttrBinary(ByVal SourceNumber, ByVal MaxValuePerIndex, ByVal MinUpperBound, ByVal IndexSeperator)
Dim lsResult, llTemp, giCount
MaxValuePerIndex = MaxValuePerIndex + 1 '(1 Based Calculations)
' Find UpperBound if Minimum Upper Bound Isn't High enough
Do While Int(SourceNumber / (MaxValuePerIndex ^ MinUpperBound)) > (MaxValuePerIndex - 1)
MinUpperBound = MinUpperBound + 1
Loop
For giCount = MinUpperBound To 0 Step -1
llTemp = Int(SourceNumber / (MaxValuePerIndex ^ giCount)) ' Get value of current index
lsResult = lsResult & CStr(llTemp) ' Add New Number to result
If giCount > 0 Then lsResult = lsResult & IndexSeperator ' Add Seperator?
SourceNumber = SourceNumber - (llTemp * (MaxValuePerIndex ^ giCount))
Next
ConvertAttrBinary = lsResult
End Function

FullFile_MapPathed, FullFile_UnMapPathed (either ones)

Views 4,986

Downloads 1,449

CodeID
DB ID