SharePoint Dragons

Nikander & Margriet on SharePoint

Retrieve folder using client object model that has space in its name

You have to be a little bit careful when you’re retrieving a SharePoint folder name using the client object model that has a space in its name. The correct way to do it is to replace the space with “%20”:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Microsoft.SharePoint;

using Microsoft.SharePoint.Client;

namespace ConsoleApplication1


    class Program


        static void Main(string[] args)




                //string folderName = “/MyDox/Test”;

                string folderName = “/MyDox/Name%20withSpace”;

                ClientContext context = new ClientContext(“http://astro“);

                Web web = context.Web;

                List list = context.Web.Lists.GetByTitle(“MyDox”);

Folder folder = web.GetFolderByServerRelativeUrl(folderName);               







            catch (Exception err)







2 responses to “Retrieve folder using client object model that has space in its name

  1. Bjoern H Rapp June 20, 2012 at 9:38 pm

    Hi Margriet. Nice sample, although I’d guess this line: List list = context.Web.Lists.GetByTitle(“MyDox”); and the corresponding Load() are leftovers.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: