title: Filtering out hidden and system sharepoint folders on windows phone 7
body: <p>I am working with sharepoint site using classes in the Microsoft.Sharepoint.Client namespace.
  As i am working on Windows Phone 7, i can not find the SPFolderCollection/SPFolder classes.</p>
  
  <p>I need to filter out hidden folders and system folders (e.g._vti_pvt).</p>
  
  <p>I found an example as follows:</p>
  
  <pre><code>// filter the folders like “_catalogs” or “_private”
                  if (folder.ParentListId != Guid.Empty)
                  {
                      SPList list  = web.Lists[folder.ParentListId];
  //filter the folders like “Reporting Templates” or “IWConvertdForms”
                      if (list.Hidden == false)
  </code></pre>
  
  <p>(The example taken from <a href="http://go4answers.webhost4life.com/Example/know-spfolder-invisible-visible-27871.aspx" rel="nofollow">http://go4answers.webhost4life.com/Example/know-spfolder-invisible-visible-27871.aspx</a>).</p>
  
  <p>However, as i have no 'SP' classes, i can't implement it on Windows Phone (no ParentListId method).</p>
  
  <p>Any ideas/workarounds would be much appreciated.</p>
  
  <p>Thank you.</p>
  
  <p>P.S. Please note, i would like to avoid using CAML at all costs; i only need to be able to list and retrieve urls of files and folders, i do not need to work with lists or notifications.</p>
  
  <p><strong>UPDATE</strong>
  So it seems i can circumvent the limitation as follows:</p>
  
  <pre><code>Foldercollection folder_assist = new FolderCollection( WHAT DO I PUT HERE??? );
      ctx.Load(folders);
                  ctx.ExecuteQueryAsync(delegate(object sender1, ClientRequestSucceededEventArgs args)
                  {
                  foreach (Folder f in folders)
                  {
                      ctx.Load(f.ParentFolder);
                  }
                  ctx.ExecuteQuery();
                  foreach (Folder f in folders)
                  {
                      List ejh;
                       // if we are in the top folder, the .parentfolder may be null
                      if (f.ParentFolder != null &amp;&amp; f.ParentFolder.Name != "")
                      {
                          ejh = ctx.Web.Lists.GetByTitle(f.ParentFolder.Name);
                      }
                      else
                      {
                          ejh = ctx.Web.Lists.GetByTitle(f.Name);
                      }
                      ctx.Load(ejh);
  
                      try
                      {
                          ctx.ExecuteQuery();
                      }
                      catch
                      {
                          ejh = null;
                      }
                      if (ejh != null)
                      {
                          if (ejh.Id != Guid.Empty)
                          {
                              if (ejh.Hidden == false)
                              {
                       folder_assist.Add(f.ServerRelativeURL;
                           }
                          }
                      }
                  } 
                  win.Dispatcher.BeginInvoke((Action)(() =&gt; DO SOME WORK...
  
              }, delegate(object sender1, ClientRequestFailedEventArgs args)
                  {
                     win.Dispatcher.BeginInvoke((Action)(() =&gt; MessageBox.Show("something went wrong" + args.ToString())));
                  });
  </code></pre>
  
  <p>The problem i am experiencing now is with the firstline - it seems Microsoft.Sharepoint.FolderCollection constructor requires the context (which i have and can pass easy) and the ObjectPath type, which i don't have since i just need a placeholder to collect all of the folders that are not hidden and not special.</p>
  
  <p>How do i work around this?</p>
  
  <p><strong>Update 2</strong></p>
  
  <p>Okay, pretty obvious outcome, i just used <code>List&lt;Folder&gt;</code> for fassist.</p>
  
  <p>However, there are two more things that i noticed:</p>
  
  <p>a) the performance of my solution is rather appalling. Where it took moments to get a list before (when i wasn't filtering in the async thread), it now takes a significant 10-20 seconds to get the list (and i only have a handful of items on the server!).</p>
  
  <p>Any ideas/suggestions? (the real problem is i cant just pass folders collection back to UI thread to parse and add one by one as i would still need to executequery for the parentFolder. And if i try to do that in async while in the foreach() loop in the UI thread, i get a noninstantiated object as the UI thread does not wait for the execution of the query. If i make it wait using the AutoResetEvent, the UI thread just becomes locked. And WP7 does not allow to use ClientContext.Executequery() in the UI thread. Bummer.)</p>
  
  <p>b) I seem to still have the 'Forms' folders within every folder i access!
  Working on that right now, but any ideas would be much appreciated.</p>