近来测试的时候,有做到一些保存文件的部分.于是同事拿去他那里跑,但是不知道不成功,因为我有的文件夹他没有,于是就想到了用VBS创建文件夹,在创建的时候去检索一下是否在此盘下有此文件夹,如果有的话,就不创建,如果没有的话,就弹出对话框,询问是否创建文件夹.这样就方便多了,只需要在调用此函数的时候,把盘符和文件名传过去就行了.
'create the foloder
Sub AddNewFolder(path, folderName)
Dim fso, f, fc, nf,msg,fso1
Set fso = CreateObject("scrīpting.FileSystemObject")
Set f = fso.GetFolder(path)
Set fso1= CreateObject("scrīpting.FileSystemObject")
Set fc=f.SubFolders
If not (fso1.FolderExists(path&folderName)) Then
'msgbox "exists "
' Else
msg= MsgBox ("create the folder?", 4, "not find the test folder!")
If msg=6 Then '6yes,7no
Set nf = fc.Add(folderName)
End If
' Else
' Set nf = fc.Add("New Folder")
'End If
End If
end sub
调用函数
Dim te,te1
ExecuteFile "C:Program FilesMercury InteractiveQuickTest PlusscrīptsAndTestsCreateFolder.vbs"
te="e:"
te1="test"
Call AddNewFolder(te,te1)
本文发布于:2024-02-04 14:09:08,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170708962156241.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |