How to find the Listitem metadata info Client Object Model

Yesterday, some one on my last blog   Two ways to Upload file from Client Object Model , asked how to find out the metadata info of the file from COM.

So the following code  give you the general idea how to find out that metadata info of the file from Client Object Model


ClientContext cc = new ClientContext("http://server:5421");
Web web = cc.Web;
cc.Load(web);
cc.ExecuteQuery();
string webName = web.Title;
string uploadLocation = string.Empty;

List list = cc.Web.Lists.GetByTitle("Documents");
cc.Load(list);
cc.Load(list.ContentTypes);
cc.Load(list.Fields);
ListItem item;

// this is how you can get the item(file), you can also use CAML query
cc.Load(item = list.GetItemById(22));

//here you can get the dictonary for fieldvalue
cc.Load(item.FieldValuesAsText);
cc.ExecuteQuery();

string createdby = item.FieldValuesAsText["Created_x0020_By"];
string modifiedby = item.FieldValuesAsText["Modified_x0020_By"];

Enjoy 🙂

Happy SharePointing 🙂

One thought on “How to find the Listitem metadata info Client Object Model

  1. Hi Shakir,
    It is nice to read your blog. I wasnt aware of “cc.Load(item = list.GetItemById(22)); ” syntax. One more thing, are you using FieldValuesAsText just to make lightweight and easy data type handling? How about payload just because you are fetching all field values.

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s