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)

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 2766 Downloads 975


ANmarAmdeen
612
File System Classic ASP
Revisions

v2.0

Needs