properti FolderItem.Name

Mengatur atau mendapatkan nama item.

Properti ini bersifat baca/tulis.

Sintaks

strName = FolderItem.Name
FolderItem.Name = strName

Nilai properti

Variabel jenis BSTR yang menentukan atau menerima nama item.

Contoh

Contoh berikut menggunakan Nama untuk mengambil nama file Autoexec.bat, lalu mengatur ulang nama ke Test.bat. Penggunaan yang tepat ditampilkan untuk Jscript, VBScript, dan Visual Basic.

Jscript:

<script language="JScript">
    function fnNameGetSetJ()
    {
        var objShell = new ActiveXObject("shell.application");
        var objFolder2;
        
        objFolder2 = objShell.NameSpace("C:\\");
        if (objFolder2 != null)
        {
            var objFolderItem;
            
            objFolderItem = objFolder2.ParseName("AUTOEXEC.BAT");
            if (objFolderItem != null)
            {
                var szReturn;
                
                szReturn = objFolderItem.Name;
                objFolderItem.Name = "TEST.BAT";
            }
        }
    }
</script>

Vbscript:

<script language="VBScript">
    function fnNameGetSetVB()
        dim objShell
        
        set objShell = CreateObject("shell.application")
        if (not objShell is nothing) then
            dim objFolder2
                
            set objFolder2 = objShell.NameSpace("C:\")
            if (not objFolder2 is nothing) then
                dim objFolderItem
                        
                set objFolderItem = objFolder2.ParseName("AUTOEXEC.BAT")
                if (not objFolderItem is nothing) then
                    dim szReturn
                                
                    szReturn = objFolderItem.Name
                    objFolderItem.Name = "TEST.BAT"
                end if
                set objFolderItem = nothing
            end if
            set objFolder2 = nothing
        end if
        set objShell = nothing
    end function
 </script>

Visual Basic:

Private Sub fnNameGetSetVB()
    Dim objShell   As Shell
    Dim objFolder2 As Folder2
    
    Set objShell = New Shell
    Set objFolder2 = objShell.NameSpace("C:\")
        If (Not objFolder2 Is Nothing) Then
            Dim objFolderItem As FolderItem
            
            Set objFolderItem = objFolder2.ParseName("AUTOEXEC.BAT")
                If (Not objFolderItem Is Nothing) Then
                    Dim szReturn As String
                    
                    szReturn = objFolderItem.Name
                    objFolderItem.Name = "TEST.BAT"
                Else
                    'FolderItem object returned nothing.
                End If
            Set objFolderItem = Nothing
        Else
            'Folder object returned nothing.
        End If
    Set objFolder2 = Nothing
    Set objShell = Nothing
End Sub

Persyaratan

Persyaratan Nilai
Klien minimum yang didukung
Windows 2000 Professional, Windows XP [khusus aplikasi desktop]
Server minimum yang didukung
Windows 2000 Server [hanya aplikasi desktop]
Header
Shldisp.h
IDL
Shldisp.idl
DLL
Shell32.dll (versi 4.71 atau yang lebih baru)