title: Alfresco programmatically navigate to correct folder
body: <p>I have a question regarding Alfresco and dotCMIS library. Basically i would like to get to a particular folder and create there a document.</p>
  
  <p>At this time i have the following code (i know it is messy, but it was for testing):</p>
  
  <pre><code> Dictionary&lt;string, string&gt; parameters = new Dictionary&lt;string, string&gt;();
  
              parameters[SessionParameter.BindingType] = BindingType.AtomPub;
              parameters[SessionParameter.AtomPubUrl] = "http://webadress:2005/alfresco/service/cmis";
              parameters[SessionParameter.User] = "amdin";
              parameters[SessionParameter.Password] = "admpsw";
  
              SessionFactory factory = SessionFactory.NewInstance();
              IList&lt;DotCMIS.Client.IRepository&gt; repositories = factory.GetRepositories(parameters);
              DotCMIS.Client.ISession session = repositories[0].CreateSession();
  
              foreach (ICmisObject cmisObject in rootFolder.GetChildren())
              {
                  Console.WriteLine(cmisObject.Name);
                  if (cmisObject.Name.Equals("AlfresCO"))
                  {
                      var type = cmisObject.GetType();
                      IFolder circabcfolder = cmisObject as IFolder;
                      foreach (ICmisObject obj in circabcfolder.GetChildren())
                      {
                          Console.WriteLine(obj.Name);
                          if (obj.Name.Equals("SubFolder1"))
                          {
                              IFolder circabcfolder2 = obj as IFolder;
                              foreach (ICmisObject obj2 in circabcfolder2.GetChildren())
                              {
                                  Console.WriteLine(obj2.Name);
  
                                  foreach (ICmisObject obj3 in (obj2 as IFolder).GetChildren())
                                  {
                                      Console.WriteLine(obj3.Name);
                                      if (obj3.Name.Equals("Library"))
                                      {
                                          foreach (ICmisObject obj4 in (obj3 as IFolder).GetChildren())
                                          {
                                              Console.WriteLine(obj4.Name);
                                              if (obj4.Name.Equals("MyFolder"))
                                              {
                                                  IDictionary&lt;string, object&gt; properties2 = new Dictionary&lt;string, object&gt;();
                                                  properties2[PropertyIds.ObjectTypeId]= "cmis:folder";
                                                  properties2[PropertyIds.Name] = "Test Folder";
  
                                                  IFolder newFolder = (obj4 as IFolder).CreateFolder(properties2);
  
                                              }
                                          }
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
  </code></pre>
  
  <p>It just opens a root folder, this means i'm in 'alfresco' for example, then i have to navigate to another sub folder and then another one, and then finally i get to:
  /Library, /Groups, /Newsgroups ... etc.
  And in Library i can open "My Folder", but is there a more easier way to just open /Library/MyFolder instead of really going through all the layers getting the right folder ...?</p>
  
  <p>Can i do something like .. <code>session.GetFolderByName("MyFolder")</code></p>
  
  <p>I can't also rely on ID, as for example in other portal the ID that is randomly generated for a folder can be different, so i cannot say GetFolderById(..);</p>
  
  <p>So any idea?</p>