【发布时间】:2019-10-02 18:40:17
【问题描述】:
我正在使用以下代码使用 C# 将文件签入到 SharePoint 2016。但它抛出 Microsoft.SharePoint.Client.ServerException: File Not Found. 文件 URL 有效,并且在控制台中打印 file.name 以确认其有效性。请告知这里出了什么问题。
string url = "valid url of the file";
var file = clientContext.Web.GetFileByServerRelativeUrl(url);
clientContext.Load(file);
clientContext.ExecuteQuery();
Console.WriteLine(file.Name); //successfully printed expected result
file.CheckIn("Test", CheckinType.MajorCheckIn);
clientContext.Load(file);
clientContext.ExecuteQuery(); //File Not Found Exception thrown at this point
【问题讨论】:
-
为什么要在上下文中加载文件两次?
-
即使在我删除加载后,它也无法正常工作并引发同样的错误。
标签: c# sharepoint automation sharepoint-2016