.NET Sharepoint Crear directorio
-
20-08-2019 - |
Pregunta
Puedo subir un archivo a sharepoint con el cliente web de la siguiente manera
using (System.Net.WebClient webclient = new System.Net.WebClient())
{
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(
Encryptor.Decrypt(ConfigurationManager.AppSettings["username"]),
Encryptor.Decrypt(ConfigurationManager.AppSettings["password"]),
ConfigurationManager.AppSettings["domain"]);
webclient.Credentials = credentials;
string path = Path.Combine("http://sharepoint.domain.com/dir", filename);
webclient.UploadData(path, "PUT", fileBytes);
}
Pero no sé cómo crear directorios si no existen.
¿Alguna idea de cómo puedo hacer eso?
Gracias -c
Solución
El término " Directorios " en un sitio de SharePoint es engañoso. La estructura de 'directorio' de un servicio web de SharePoint es una estructura virtual que se encuentra en las bases de datos de SharePoint. Debe identificar qué objeto en el Modelo de objetos de SharePoint es, por ejemplo, el 'directorio': http: //sharepoint.domain .com / dir es probablemente un SPSite, en el sitio puede tener un 'directorios' que son SPFolders, SPLists, SPDocumentLibraries etc.
Entonces, si " crea directorios que no existen " quiere decir que en la estructura de directorios del sitio de SharePoint, no podrá hacerlo con el WebClient. Tiene dos opciones: el modelo de objetos de Windows SharePoint Services y los servicios web de SharePoint.
El modelo de objetos es ciertamente más fácil de usar en mi opinión, pero requerirá que ejecute la aplicación en el mismo servidor que su servidor de SharePoint. Los servicios web requieren un poco más de trabajo, pero le permiten usarlos de forma remota.
Deberá identificar qué tipo de objeto está tratando de agregar (por ejemplo, SPFolder, SPSite, SPList, SPDocumentLibrary ect.).
Existe una amplia documentación para usar el modelo de objetos ubicado Aquí pero si desea utilizar los servicios web, deberá acceder a ellos en las siguientes ubicaciones:
Administration Service http://<server-url:port-number>/_vti_adm/admin.asmx
Alerts Service http://<server-url>/_vti_bin/alerts.asmx
Document Workspace Service http://<server-url>/_vti_bin/dws.asmx
Forms Service http://<server-url>/_vti_bin/forms.asmx
Imaging Service http://<server-url>/_vti_bin/imaging.asmx
List Data Retrieval Service http://<server-url>/_vti_bin/dspsts.asmx
Lists Service http://<server-url>/_vti_bin/lists.asmx
Meetings Service http://<server-url>/_vti_bin/meetings.asmx
Permissions Service http://<server-url>/_vti_bin/permissions.asmx
Site Data Service http://<server-url>/_vti_bin/sitedata.asmx
Site Service http://<server-url>/_vti_bin/sites.asmx
Users and Groups Service http://<server-url>/_vti_bin/usergroup.asmx
Versions Service http://<server-url>/_vti_bin/versions.asmx
Views Service http://<server-url>/_vti_bin/views.asmx
Web Part Pages Service http://<server-url>/_vti_bin/webpartpages.asmx
Webs Service http://<server-url>/_vti_bin/webs.asmx
Sugiero buscar en los servicios de Listas o Servicio de documentos del espacio de trabajo.
Espero que eso ayude.