internal void CheckDocumentSetMapping(List docsetlist, string relativeUrl) { Folder docsetfolder = ClientContext.Web.GetFolderByServerRelativeUrl(relativeUrl); ClientContext.Load(docsetfolder, fld => fld.Name, fld => fld.ParentFolder.Name, fld => fld.ServerRelativeUrl, fld => fld.ListItemAllFields); ClientContext.ExecuteQueryRetry(); var onlineurl = relativeUrl.Replace(docsetlist.RootFolder.ServerRelativeUrl, ""); var localdocuset = FullDocumentSetPath(this.TargetLocation, onlineurl, docsetfolder.Name); DocumentSet docSet = DocumentSet.GetDocumentSet(ClientContext, docsetfolder); var docSetStream = docSet.ExportDocumentSet(); ClientContext.ExecuteQueryRetry(); using (var fs = new System.IO.FileStream(localdocuset.FullName, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None)) { docSetStream.Value.CopyTo(fs); } }