向 Folders 集合中添加新的文件夹。
object.Add (folderName)
下面的例子说明了使用 Add 方法创建新文件夹的方法。
[JScript] function AddNewFolder(path,folderName) { var fso, f, fc, nf; fso = new ActiveXObject("Scripting.FileSystemObject"); f = fso.GetFolder(path); fc = f.SubFolders; if (folderName != "" ) nf =fc.Add(
folderName)
; else nf =fc.Add(
"New Folder")
; } [VBScript] Sub AddNewFolder(path, folderName) Dim fso, f, fc, nf Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder(path) Set fc = f.SubFolders If folderName <> "" Then Set nf =fc.Add(
folderName)
Else Set nf =fc.Add(
"New Folder")
End If End Sub
如果 folderName 已经存在了,则会出错。