SPWeb.GetFolder method (Guid)

Retrieves the folder object with the specified GUID.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Public Function GetFolder ( _
	uniqueId As Guid _
) As SPFolder
Dim instance As SPWeb
Dim uniqueId As Guid
Dim returnValue As SPFolder

returnValue = instance.GetFolder(uniqueId)


Type: System.Guid

A GUID that identifies the folder.

Return value

Type: Microsoft.SharePoint.SPFolder
The folder with the specified GUID.

The user must have BrowseDirectories permissions to use this method.

The following example is a console application that demonstrates two ways of getting an SPFolder object for a folder named "Test folder" in the "Shared Documents" list.

Imports System
Imports Microsoft.SharePoint

Module ConsoleApp
   Sub Main()
      Using site As SPSite = New SPSite("http://localhost")
         Using web As SPWeb = site.OpenWeb()

                If (web.DoesUserHavePermissions(SPBasePermissions.BrowseDirectories)) Then

                    ' Get a folder by server-relative URL.
                    Dim url As String = web.ServerRelativeUrl + "/shared documents/test folder"
                    Dim folder As SPFolder = web.GetFolder(url)

                        ' Get the folder's Guid.
                        Dim id As Guid = folder.UniqueId

                        ' Get a folder by Guid.
                        folder = web.GetFolder(id)
                        url = folder.ServerRelativeUrl

                    Catch ex As System.IO.FileNotFoundException
                    End Try

                End If

         End Using
      End Using
   End Sub
End Module