'************************************
'函数功能:获取项目路径并返回
'输入参数:
' 无
'返回值:
' 返回类型,目录对象
'示例调用:
'temp = GetPath
'*************************************
Public Function GetPath
On Error Resume Next
GetPath= createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path
'GetPath = CreateObject("Scripting.FileSystemObject").GetFolder(".").Path
If Err.Number<>0 Then
MsgBox Err.Description
Err.Clear
End If
End Function
'函数功能:获取项目路径并返回
'输入参数:
' 无
'返回值:
' 返回类型,目录对象
'示例调用:
'temp = GetPath
'*************************************
Public Function GetPath
On Error Resume Next
GetPath= createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path
'GetPath = CreateObject("Scripting.FileSystemObject").GetFolder(".").Path
If Err.Number<>0 Then
MsgBox Err.Description
Err.Clear
End If
End Function
本文介绍了一个使用VBScript编写的函数GetPath,该函数能够获取当前脚本所在的项目路径并返回。此函数通过创建Scripting.FileSystemObject对象来实现路径获取,并提供了错误处理机制。

被折叠的 条评论
为什么被折叠?



