FolderItem.Name-Eigenschaft
Legt den Namen des Elements fest oder ruft diesen ab.
Dies ist eine Eigenschaft mit Lese- und Schreibzugriff.
Syntax
strName = FolderItem.Name
FolderItem.Name = strName
Eigenschaftswert
Eine Variable vom Typ BSTR , die den Namen des Elements angibt oder empfängt.
Beispiele
Im folgenden Beispiel wird Name verwendet, um den Namen der Autoexec.bat-Datei abzurufen, und setzen Sie den Namen dann auf Test.bat zurück. Die ordnungsgemäße Verwendung wird für JScript, VBScript und Visual Basic angezeigt.
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
Anforderungen
Anforderung | Wert |
---|---|
Unterstützte Mindestversion (Client) |
Windows 2000 Professional, Windows XP [nur Desktop-Apps] |
Unterstützte Mindestversion (Server) |
Windows 2000 Server [nur Desktop-Apps] |
Header |
|
IDL |
|
DLL |
|