Featured post

Welcome

Welcome to my blog.
I am a Microsoft Certified Professional in C# with more than 10 yrs experience in Microsoft technology developing and designing different enterprise applications.
My specialty is developing SharePoint application in client side object model.
This blog will contain SharePoint codes and techniques which I’ve learnt while developing SharePoint applications.
Hope this blog will be helpful for you.
Enjoy reading and learning.

How to Get Library Name via Url Programmatically in SharePoint 2013 using client side (CSOM)

Just like site name, sometimes or most of the time, the url is different from the name of the library.
For example:
The url will be like “http://roel2013/sites/t1/lib1” but the library name is “library”
So we must not rely on the url for the library name.
To get the library name programatically, use the code below.

but this will only work if the url ends in a library url, what if the end of the url is folder or docset?
or a folder within a folder within a folder?
Have no fear, the ghostbusters are here.
Use the code below.

How to Get Site name Programmatically in SharePoint 2013 using client side (CSOM)

This might be pretty basic, but it’s good to know 🙂
Sometimes or most of the time, the url is different from the name of the site.
For example:
The url will be like “http://roel2013/sites/t1” but the site name is “testing”
So we must not rely on the url for the site name.
To get the site name programatically, use the code below.

How to Get Followed Sites Programmatically in SharePoint 2013 using client side (CSOM)

Add as Reference
Microsoft.SharePoint.Client.UserProfiles.dll

Add using
using Microsoft.SharePoint.Client.Social;

SocialFollowingManager is the key to check the followed sites

How to UnFollow Site or Stop Following Sites Programmatically in SharePoint 2013 using client side (CSOM)

Add as Reference
Microsoft.SharePoint.Client.UserProfiles.dll

Add using
using Microsoft.SharePoint.Client.Social;

SocialFollowingManager is the key to check the followed sites

How to Follow Site Programmatically in SharePoint 2013 using client side (CSOM)

Add as Reference
Microsoft.SharePoint.Client.UserProfiles.dll

Add using
using Microsoft.SharePoint.Client.Social;

SocialFollowingManager is the key to check the followed sites

Get ContentType Id base on ContentType Name(s)

Check if file exists in subfolder without using an exception

If you check the blog post in “Check if file exists in list/library without using an exception”
the method here is somewhat similar, with some few additional tricks

Here we need serverRelativeUrl variable

The key here is in the xmlQuery, we added Scope=’RecursiveAll’, which looks entirely in a library, but we will limit the search only to our location with

and {1} is the serverRelativeUrl

Check if file exists in list/library without using an exception

This is all well and good, but this won’t work if the file is in subfolder.
See “Check if file exists in subfolder without using an exception”

Get Columns or Fields of a Content Type

Get Content Type of a File or Folder in a List/Library

If it’s a folder, replace the filename with a folder name