(Guid) del método SPWeb.GetFolder
Recupera el objeto de carpeta con el GUID especificado.
Espacio de nombres: Microsoft.SharePoint
Ensamblado: Microsoft.SharePoint (en Microsoft.SharePoint.dll)
Sintaxis
'Declaración
Public Function GetFolder ( _
uniqueId As Guid _
) As SPFolder
'Uso
Dim instance As SPWeb
Dim uniqueId As Guid
Dim returnValue As SPFolder
returnValue = instance.GetFolder(uniqueId)
public SPFolder GetFolder(
Guid uniqueId
)
Parámetros
uniqueId
Tipo: System.GuidUn GUID que identifica la carpeta.
Valor devuelto
Tipo: Microsoft.SharePoint.SPFolder
La carpeta con el GUID especificado.
Comentarios
El usuario debe tener permisos de BrowseDirectories para usar este método.
Ejemplos
En el siguiente ejemplo es una aplicación de consola que muestra dos maneras de obtener un objeto SPFolder para una carpeta denominada "Carpeta de prueba" en la lista "Documentos compartidos".
Imports System
Imports Microsoft.SharePoint
Module ConsoleApp
Sub Main()
Using site As SPSite = New SPSite("https://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)
Try
' Get the folder's Guid.
Dim id As Guid = folder.UniqueId
Console.WriteLine(id)
' Get a folder by Guid.
folder = web.GetFolder(id)
url = folder.ServerRelativeUrl
Console.WriteLine(url)
Catch ex As System.IO.FileNotFoundException
Console.WriteLine(ex.Message)
End Try
End If
End Using
End Using
Console.ReadLine()
End Sub
End Module
using System;
using Microsoft.SharePoint;
namespace Test
{
class ConsoleApp
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("https://localhost"))
{
using (SPWeb web = site.OpenWeb())
{
if (web.DoesUserHavePermissions(SPBasePermissions.BrowseDirectories))
{
// Get a folder by server-relative URL.
string url = web.ServerRelativeUrl + "/shared documents/test folder";
SPFolder folder = web.GetFolder(url);
try
{
// Get the folder's Guid.
Guid id = folder.UniqueId;
Console.WriteLine(id);
// Get a folder by Guid.
folder = web.GetFolder(id);
url = folder.ServerRelativeUrl;
Console.WriteLine(url);
}
catch (System.IO.FileNotFoundException ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
Console.ReadLine();
}
}
}