Folder.NewFolder method
Creates a new folder.
Syntax
Folder.NewFolder(
bName,
[ vOptions ]
)
Parameters
-
bName
-
Type: BSTR
A string that specifies the name of the new folder.
-
vOptions [optional]
-
Type: Variant
This value is not currently used.
Return value
This method does not return a value.
Remarks
Note
Not all methods are implemented for all folders. For example, the ParseName method is not implemented for the Control Panel folder (CSIDL_CONTROLS). If you attempt to call an unimplemented method, a 0x800A01BD (decimal 445) error is raised.
Examples
The following example uses NewFolder to create the new folder C:\TestFolder. Proper usage is shown for JScript, VBScript, and Visual Basic.
JScript:
<script language="JScript">
function fnFolderObjectNewFolderJ()
{
var objShell = new ActiveXObject("shell.application");
var objFolder = new Object;
objFolder = objShell.NameSpace("C:\\");
if (objFolder != null)
{
objFolder.NewFolder("TestFolder");
}
}
</script>
VBScript:
<script language="VBScript">
function fnFolderObjectNewFolderVB()
dim objShell
dim objFolder
set objShell = CreateObject("shell.application")
set objFolder = objShell.NameSpace("C:\")
if (not objFolder is nothing) then
objFolder.NewFolder("TestFolder")
end if
set objFolder = nothing
set objShell = nothing
end function
</script>
Visual Basic:
Private Sub btnNewFolder_Click()
Dim objShell As Shell
Dim objFolder As Folder
Set objShell = New Shell
Set objFolder = objShell.NameSpace("C:\")
If (Not objFolder Is Nothing) Then
objFolder.NewFolder ("TestFolder")
End If
Set objFolder = Nothing
Set objShell = Nothing
End Sub
Requirements
Requirement | Value |
---|---|
Minimum supported client |
Windows 2000 Professional, Windows XP [desktop apps only] |
Minimum supported server |
Windows 2000 Server [desktop apps only] |
Header |
|
IDL |
|
DLL |
|