我的应用程序通过 Web 客户端/WebDAV(WebDAV 重定向器)编辑 SharePoint 中的文件。我如何办理退房/入住手续?

StackOverflow https://stackoverflow.com/questions/537990

  •  22-08-2019
  •  | 
  •  

我正在集成我的应用程序,以便它可以编辑存储在 SharePoint 中的文件。我正在使用 Web 客户端服务 AKA WebDAV Redirector(webclnt.dll),它可以很好地让正常的 CreateFile/读/写 Windows api 调用通过 WebDAV 从其正常驱动器 I/O 路径重定向到网络。但是,如果文件已签入,我只能获得对该文件的只读访问权限。

使用 Web 客户端服务,如何在编辑文件时将其签出,然后在完成编辑后将其签入?

编辑:我尝试使用 GetFileAttributes 和 SetFileAttributes 来测试 FILE_ATTRIBUTE_READONLY,希望我可以使用该标志来确定文件何时未检出,然后将其检出(通过取消设置该标志来检出,然后将其设置为检查)在)。运气不好;该文件始终显示为非只读。

有帮助吗?

解决方案

要执行签入/签出文件,您需要使用以下代码:

SPSite oSite = new SPSite ("http://<sitename>/");
SPWeb oWeb = oSite.OpenWeb(); 
SPList oList = oWeb.Lists["Shared Documents"];
SPListItem oListItem = oList.Items[0]; //taking the first list item
oListItem.File.CheckOut();
oListItem["Name"] = "xyz";           
oListItem.Update();
oListItem.File.CheckIn("file name has been changed");

如果您需要通过 SharePoint WebService 进行签入/签出,那么您应该查看 Brad McCable 博客上的代码 Windows Sharepoint 服务 Web 服务示例.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top