我正在使用Microsoft.SharePoint.Client
来处理asp.net MVC项目中的SharePoint 2013文件。我能够加载文件然后执行查询但加载后,我必须签出文件。结账时我收到以下错误:
网址无效。它可能引用不存在的文件或文件夹,或引用当前Web中不存在的有效文件或文件夹。
我只通过asp.net MVC项目创建了这个文件。通过代码在Sharepoint上创建文件时很好。我还直接从SharePoint检出了该文件。它在那里工作得很好。
注意: - 需要结账的文件位于子网站下。
以下是我的示例代码:
//siteUrl = xxx.com
//subsite = acct
//relUrl = /acct/doclib/test.txt
using (ClientContext ctx = getContext(siteUrl))
{
var site = ctx.Web;
var file = site.GetFileByServerRelativeUrl(relUrl);
try
{
ctx.Load(file)
ctx.ExecuteQuery();
if (file.CheckOutType == CheckOutType.None)
{
file.CheckOut();
ctx.ExecuteQuery(); // this line is causing error
return true;
}