0

I am not able checkin/checkout the files in sub folders in the document library using client object model. Below is the code I am using.

public void CheckOut()// CHECK OUT FUNCTION 
{
    try
    {
        string siteurl = "";
        string filePath = "";

        ClientContext context = new ClientContext(siteurl);
        context.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

        Web web = context.Web;
        File file = web.GetFileByServerRelativeUrl(filePath);

        file.CheckOut();
        context.Load(web);
        context.Load(file);
        context.ExecuteQuery();
        if (file.CheckOutType == CheckOutType.None)
        {
            file.CheckOut();
        }
        context.Load(file);
        context.ExecuteQuery();
    }
    catch (Exception ex)
    {
    }
}


public void Checkin()// CHECK-IN FUNCTION 
{
    try
    {

        string filePath = "";
        ClientContext context = new ClientContext("");

        context.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

        Web web = context.Web;
        File file = web.GetFileByServerRelativeUrl(filePath);
        //  file.CheckIn();
        file.CheckIn(string.Empty, CheckinType.MajorCheckIn);
        context.Load(file);
      context.ExecuteQuery();
    }
    catch (Exception ex)
    {

    }


}
  • And what is your problem exaclty? – jjczopek Dec 5 '13 at 21:49
  • I am not able to checkin/checkout the files in subfolder in document library. – Kishan Dec 5 '13 at 22:42
  • Whether there are any errors during execution? – Vadim Gremyachev Dec 7 '13 at 20:57
  • No there were no any errors. The Problem is i am not able to hit on the folder(sub-folder document library) – Kishan Dec 8 '13 at 20:14
1

Make sure your Site Url and file path is correct.

Example of File Path: /sites/siteName/LibraryName/FolderName/Details.csv

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.