SetAttr

Sets an attribute to file or folder
Needs to have variables defined as you see in code below.
Needs the MapPath version of a file/folder
Assumes file if a . was found in filename, if not, it assumes it is a folder (might need some work here)

CodeFunctionName
What is this?

Public

Not Tested

Original Work
vbNormal = 0
vbReadOnly = 1
vbHidden = 2
vbSystem = 4
vbArchive = 32
Private Sub SetAttr(byVal pathname_MapPathed, byVal attributes)
Dim objFSO, objFile, objFolder, boolErr, strErrDesc
On Error Resume Next
Set objFSO = Server.CreateObject("scripting.filesystemobject")
If instr( right( pathname, 4 ), "." ) then
' probably a file
Set objFile = objFSO.GetFile(pathname_MapPathed)
objFile.Attributes = attributes
Set objFile = Nothing
Else
' probably a directory or folder
Set objFolder = objFSO.GetFolder(pathname_MapPathed)
objFolder.Attributes = attributes
Set objFolder = Nothing
End If
If Err Then
boolErr = True
strErrDesc = Err.Description
End If
Set objFSO = Nothing
On Error GoTo 0
if boolErr then Err.Raise 5103, "SetAttr Statement", strErrDesc
End Sub

pathname_MapPathed, attributes

SetAttr server.mappath("/New Folder"), vbHidden
SetAttr "C:\New Folder", 2

Views 4,637

Downloads 1,505

CodeID
DB ID