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)

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
   ' 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(&#34;/New Folder&#34;), vbHidden<br/>SetAttr &#34;C:\New Folder&#34;, 2

Views 251 Downloads 112

'FSO', 'GetAttr', 'SetAttr', 'File', 'Folder', 'NeedWork', 'MapPath', 'System', 'FSO', 'FileSystemObject', 'Attributes', 'read-only', 'hidden', 'readonly', 'archive'

File System Classic ASP