programming-examples/asp/FilesMaths/SetAttr Statement.asp

35 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

2019-11-18 14:25:58 +01:00
example usage:
Makes the directory New Folder On the C drive's root hidden.
<% SetAttr "C:New Folder", 2 %>
Makes the directory New Folder On the server's root hidden.
<%
Const vbHidden = 2
SetAttr Server.MapPath("/New Folder"), vbHidden
%>
source code:
<%
Private Sub SetAttr(ByVal pathname, 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)
objFile.Attributes = attributes
Set objFile = Nothing
Else
' probably a directory or folder
Set objFolder = objFSO.GetFolder(pathname)
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
%>