Sharepoint 2010 - Modelo de objetos - Descargar DocumentSet mediante programación

A code snippet of how i can download a documentSet programmatically using the sharepoint object model would really help.

What I am trying to do is - Given the sharepoint site, log in with the user default credentials - look for the document library where the files are hosted - Pull the files down on to the local machine

Lo que he hecho hasta ahora

using Microsoft.SharePoint.Client;

ClientContext cc = new ClientContext(ConfigurationManager.AppSettings["site"]);
            cc.Credentials = new NetworkCredential(username, pwd, domain);
            Web site = cc.Web;
            ListCollection collList = site.Lists;

            var oList = collList.GetByTitle("Document Set test");

            // Get the document set
            cc.Load(oList);
            cc.ExecuteQuery();

            // Get All views
            var views = oList.Views;
            cc.Load(views);
            cc.ExecuteQuery();

            // Get All documents
            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml = @"<Query>
                                   <ViewFields>
                                        <FieldRef Name='Title'/>
                                        <FieldRef Name='Display Name'/>
                                   </ViewFields>
                                   <Where>
                                      <Gt>
                                         <FieldRef Name='Created' />
                                         <Value IncludeTimeValue='TRUE' Type='DateTime'>1900-05-08T14:25:50Z</Value>
                                      </Gt>
                                   </Where>   
                                   <OrderBy>
                                         <FieldRef Name='Title' Ascending='True' />
                                   </OrderBy>                                    
                                </Query>";

            var docs = oList.GetItems(camlQuery);
            cc.Load(docs);
            cc.ExecuteQuery();

            Console.WriteLine(string.Format("{0} Models in the repository", docs.Count));

foreach (var doc in docs) {

// DOWNLOAD THE DOCUMENTS in the DOCUMENT SET - BUT HOW?

                Console.WriteLine(string.Format("{0} => {1} ", Environment.NewLine, doc["Title"]));
            }
            Console.WriteLine(Environment.NewLine);

preguntado el 09 de marzo de 12 a las 13:03

I would ask sharepoint.stackexchange.com, you might find more gurus there -

msdn forums are good too, if you have not posted it there. -

haha. No hope of getting an answer on stackoverflow? I'll try msdn forum as well. -

1 Respuestas

Estarás interesado en el Microsoft.SharePoint.Client.File.OpenBinaryDirect método. Vuelve FileInformation which makes the content accessible via the Stream property. You can have a look at code examples in other thread here, El una página de MSDN ó en a Codeproject article.

And yes, there are SharePoint developers on Stackoverflow too :-)

--- Ferda

contestado el 23 de mayo de 17 a las 13:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.