Share via


WebFolder Object

SharePoint Designer Developer Reference

Represents a folder in a Web site.

Remarks

The WebFolder object is a member of the WebFolders collection.The Folder object is a pointer to the WebFolder object.The WebFolders collection represents all of the folders in a specified Web site. Within the WebFolders collection, individual WebFolder objects are indexed beginning with zero. The WebFolder object is similar to a folder in a directory-based hierarchy; however, the relationship between WebFolder objects and Web objects is unique. You can create multiple Web objects on a Web server. Any WebFolder can represent a Web site, but every WebFolder does not necessarily represent a Web site. The folder hierarchy provides the link to folders and files on a Web server directory. The navigation structure provides the underlying structure for the Web objects within individual Office SharePoint Designer–based Web sites.

Use WebFolders(Index), where Index is the property key of a folder, to return a single WebFolder object. The following example returns the file name of the first folder item in the WebFolders collection.

Visual Basic for Applications
ActiveDocument.WebFolders(0).Name

Use the collection properties such as Files, Folders, or Properties to return the collection object for the specified item. The following statements return the first specified item in the collection for the active Web site.

Visual Basic for Applications
myFileOne = ActiveWeb.RootFolder.Files(0)
myFolderOne = ActiveWeb.RootFolder.Folders(0)
myPropertyOne = ActiveWeb.Properties("vti_author")

Use properties such as IsExecutable, IsReadable, and IsRoot to check for the specified state of the folder. If you want to execute CGI scripts, you can add the scripts to a folder and set the IsExecutable property of that folder to True. When you have content in a folder that you want others to browse, you can set the IsReadable property to True. If you want to determine whether the current folder is the root folder, you can use the IsRoot property.The following example determines whether files in the current WebFolder object are executable, read-only, or located in a root folder.

Visual Basic for Applications
Private Sub GetFolderInfo()
    Dim myWeb As Web
    Dim myFolder As WebFolder
    Dim myIsExe As Boolean
    Dim myIsReadable As Boolean
    Dim myIsRoot As Boolean
    Set myWeb = ActiveWeb
    Set myFolder = myWeb.RootFolder.Folders(1)
    With myFolder
        myIsExe =.IsExecutable
        myIsReadable =.IsReadable
        myIsRoot =.IsRoot
    End With
End Sub

The IsExecutable, IsReadable, and IsWriteable properties return information about the state of the folder. The following examples show how to set the IsExecutable and IsReadable properties and read the IsWriteable property.

Note

You cannot set the IsWriteable property; however, you can set the IsExecutable and IsReadable properties for a WebFolder object.

Visual Basic for Applications
Sub FolderProperties ()
Dim myFolder As WebFolder
Set myFolder = ActiveWeb.RootFolder.Folders(0)
If myFolder.IsWritable Then
    MsgBox "Folder, " & myFolder.Url & " is writable"
End If
If Not(myFolder.IsReadable) Then
    MyFolder.IsReadable = True
End If
If myFolder.IsExecutable Then
    MyFolder.IsExecutable = False
End If
End Sub

Folders (or WebFolders collection) in Office SharePoint Designer serve two purposes. They can be folders that help manage the contents of a Web site, or they can be entire Web sites. A Web site can have multiple subsites below it. The IsWeb property returns True if the folder is a Web subsite. The following example uses the IsWeb property to determine whether a folder is a Web subsite and, if so, opens the Web site.

Note

To run this example, you must have a Web site named "C:\My Documents\My Web Sites\Coho Winery", or you may substitute an alternative Web site URL.

Visual Basic for Applications
Private Sub CheckFolder()
    Dim myFolder As WebFolder
    Set myFolder = ActiveWeb.RootFolder.Folders("Coho Winery")
    If myFolder.IsWeb = True Then
        Webs.Open myFolder.Url
    End If
End Sub

Use the Url property to return the URL of the current WebFolder object. The following statement returns the absolute URL for the eighth folder in the active Web site.

Visual Basic for Applications
myUrl = ActiveWeb.RootFolder.Folders(7).Url

Use the Copy, Delete, and Move methods to maintain your Web site structure. The following statement copies a WebFolder object from one folder to another folder, updates the links during the copy process, and forces an overwrite if the file already exists.

Visual Basic for Applications
myFolder.Copy("C:\My Web Sites\New Adventure Products", True, True)

See Also