Sharepoint 2010 CSOM-可以上传文件但无法检入

时间:2018-11-28 16:15:45

标签: sharepoint sharepoint-2010 csom

我使用以下功能将文件上传到sharepoint 2010库,对我来说很好用

    void upload()
    {
        ClientContext clientContext = new ClientContext("http://dev.sp-projects.com:880");
        Web web = clientContext.Web;
        clientContext.Load(web);
        clientContext.ExecuteQuery();

        string filePath = @"C:\SP\sp.txt";
        string filename = "sp.txt";

        using (FileStream fs = new FileStream(filePath, FileMode.Open))
        {
            Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContext, "/folder1/folder2/" + filename, fs, true);

        }

    }

但是,当我使用以下功能检查同一文件时,出现错误消息“找不到文件”

void CheckInOnly()
        {
            ClientContext clientContext = new ClientContext("http://dev.sp-projects.com:880");
            Microsoft.SharePoint.Client.File fl = clientContext.Web.GetFileByServerRelativeUrl("/folder1/folder2/sp.txt");
            clientContext.Load(fl);
            clientContext.ExecuteQuery()
            fl.CheckIn("checkin", CheckinType.MajorCheckIn);
        }

0 个答案:

没有答案