cancel
Showing results for 
Search instead for 
Did you mean: 

how to create documents at child levels in c#?

divyabharathipa
Champ in-the-making
Champ in-the-making
Hi All,


I have tried to create document at perticular folder level using c# in cmis ?

I have tried with

  foreach (ITree<IFileableCmisObject> t in root.GetDescendants(-1))
                {      
               if(t.Item.Name == txtFileUpload.Text )
                {
                    ISession session1 = factory.GetRepositories(parameters)[0].CreateSession();
                    IOperationContext oc = session1.CreateOperationContext();
                    oc.IncludeAcls = true;
                    string formattedName = Path.GetFileName(fileUpload1.FileName);
                    string Extension = Path.GetExtension(fileUpload1.PostedFile.FileName);
                    IDictionary<string, object> properties1 = new Dictionary<string, object>();
                    properties1.Add(PropertyIds.Name, formattedName);
                    properties1.Add(PropertyIds.ObjectTypeId, "cmis:document");
                    ContentStream contentStream = new ContentStream
                    {
                        FileName = formattedName,
                        MimeType = "application/msword",
                        Length = fileUpload1.FileBytes.Length,
                        Stream = new MemoryStream(fileUpload1.FileBytes)
                    };
                  
                    t.Item.Parents[0].CreateDocument(properties1, contentStream, null);
                    break;
                }
                }
but in place t.item.Parents[0] we need to write something that i am not getting. Please help me to fix this .

Thanks,
Divya Palivela
1 REPLY 1

kaynezhang
World-Class Innovator
World-Class Innovator
If you want to  create document at perticular folder ,you can
1.First use
 public ICmisObject GetObject(***) or public ICmisObject GetObjectByPath(string path)
to get specified cmis object ,then convert it to IFolder
2. Then call
ISession.CreateDocument or Ifolder.CreateDocument 
to create document in that folder.

What do you mean by "but in place t.item.Parents[0] we need to write something that i am not getting"