I am new to DOTCMIS in Sharepoint On prem 2013. I am able to get the sharepoint document library using atom pub with below code.

parameters[SessionParameter.User] = "*****";
                parameters[SessionParameter.Password] = "******";

                // connection settings
                parameters[SessionParameter.AtomPubUrl] = "http://zeus:18439/_vti_bin/cmis/rest/cd4e6a20-32dd-46f5-96a8-00ef7b754ec2?getRepositoryInfo";
                parameters[SessionParameter.BindingType] = BindingType.AtomPub;
                parameters[SessionParameter.RepositoryId] = "cd4e6a20-32dd-46f5-96a8-00ef7b754ec2";
                parameters[SessionParameter.AuthenticationProviderClass] = "DotCMIS.Binding.NtlmAuthenticationProvider";

                // create session
                ISession session = factory.CreateSession(parameters);
                migrateRepos = factory.GetRepositories(parameters);

I want to loop through all children (Sub folders & Items inside folders)..How to achieve this...glad for any help


No need for queries.

Just use GetChildren, and check the type of each children to decide whether to recurse or not:

foreach (ICmisObject cmisObject in remoteFolder.GetChildren(operationContext))
    if (cmisObject is DotCMIS.Client.Impl.Folder)
        // It is a CMIS folder.
        IFolder remoteSubFolder = (IFolder)cmisObject;
        // TODO Recurse
    else if (cmisObject is DotCMIS.Client.Impl.Document)
        // It is a CMIS document.
        IDocument remoteDocument = (IDocument)cmisObject;
        // TODO do something with it.
        // It is a CMIS link or something else.

Real-life example:


I am able to get this done by below code..

IItemEnumerable<IQueryResult> Fileresults = session.Query("SELECT * FROM cmis:document", false);
 if (Folderresults.TotalNumItems > 0)
                    arrFolderPaths = new string[Folderresults.TotalNumItems + 1];
                    int i = 0;
                    foreach (IQueryResult cmisObject1 in Folderresults)
                        string objectId = ((DotCMIS.Data.Impl.PropertyData)(cmisObject1.GetPropertyById("cmis:objectId"))).Values[0].ToString();
                        ICmisObject cmisObject = session.GetObject(objectId);
                        IFileableCmisObject fileableCmisObject = cmisObject as IFileableCmisObject;
                        paths = fileableCmisObject.Paths;
                        arrFolderPaths[i] = paths[0].ToString();
                        CreateFolderPathsInDestSP(DestCtx, DestinationlistName.RootFolder, arrFolderPaths[i]);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.