getfiledir.vbs
来自「Apress - Managing Enterprise Systems Wit」· VBS 代码 · 共 34 行
VBS
34 行
'Description
'Returns specified file or directory object
'Parameters
'strPath File name to search for
'objIISPath IIS object container to retrieve object from
Function GetFileDir(strPath, objIISPath)
Dim strObjectClass, objWebFileDir, objFSO
On Error Resume Next
'attempt to get the object from specified container
Set objWebFileDir = objIISPath.GetObject(strObjectClass, strPath)
'check if error occured - could not get object
If Err Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
'check if specified path is a file..
If objFSO.FileExists(objIISPath.Path & "\" & strPath) Then
'create the file object
Set objWebFileDir = objIISPath.create("IIsWebFile", strPath)
'check if specified path is a directory..
ElseIf objFSO.FolderExists(objIISPath.Path & "\" & strPath) Then
'create the directory object
Set objWebFileDir = objIISPath.create("IIsWebDirectory", strPath)
Else
Set objWebFileDir = Nothing
End If
End If
Set GetFileDir = objWebFileDir
End Function
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?