次の方法で共有


IsRootFolder Property

Returns True if the specified folder is the root folder; False if it is not.

                      object.IsRootFolder 

Remarks

The object is always a Folder object.

The following code illustrates the use of the IsRootFolder property:

function DisplayLevelDepth(pathspec)
{
   var fso, f, n, s = "";
   fso = new ActiveXObject("Scripting.FileSystemObject");
   f = fso.GetFolder(pathspec);
   n = 0;
   if (f.IsRootFolder)
      s = "The specified folder is the root folder."
   else
   {
      do
      { 
         f = f.ParentFolder;
         n++;
      }
      while (!f.IsRootFolder)
      s = "The specified folder is nested " + n + " levels deep."
   }
   return(s);
}
Function DisplayLevelDepth(pathspec)
   Dim fso, f, n
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFolder(pathspec)
   If f.IsRootFolder Then
      DisplayLevelDepth = "The specified folder is the root folder."
   Else
      Do Until f.IsRootFolder
         Set f = f.ParentFolder
         n = n + 1
      Loop
      DisplayLevelDepth = "The specified folder is nested " & n & " levels deep."
   End If
End Function

Applies To:

Folder Object

See Also

Reference

Attributes Property

DateCreated Property

DateLastAccessed Property

DateLastModified Property

Drive Property

Files Property (FileSystemObject)

Name Property (FileSystemObject)

ParentFolder Property

Path Property (FileSystemObject)

ShortName Property

ShortPath Property

Size Property

SubFolders Property

Type Property