代码如下例所示,假设要创建的文件夹是在C:drive.
如何用QTP脚本创建一个文件夹:
Dim strDrive, strfoldername,objFSO, objFolder, strPath
strDrive = “c:” ‘你要创建的文件夹所在的盘符
strfoldername=”test” ‘你要创建的文件夹名
strPath= strDrive&strfoldername
‘ 创建FileSystemObject.
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
On Error Resume Next ‘ 如果文件夹已经存在
‘ 用strPath创建一个文件夹
Set objFolder = objFSO.CreateFolder(strPath)
If err.Number = 58 then ‘VB script运行时异常,如果文件已经存在
msgbox “Folder already exist at” & strPath
exitTest
End If
msgbox “Folder created is at ” & strPath
评论列表
文章目录