Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
Windows Shell
Shell Reference
Folder
Methods
 NewFolder Method

  Switch on low bandwidth view
NewFolder Method

Creates a new folder.

Syntax

Folder.NewFolder(bName [, vOptions])

Parameters

bName Required. A string that specifies the name of the new folder.
vOptions Optional. This value is not currently used.

Return Value

No return 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 Microsoft JScript, Microsoft Visual Basic Scripting Edition (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

Applies To

Folder
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker