【问题标题】:update file in Document library更新文档库中的文件
【发布时间】:2013-01-18 06:20:53
【问题描述】:

我正在开发一个需求事件接收器,使用第三方 DLL 将页面内容生成到 Microsoft WordPDF 中。生成完成后,我需要将其上传到文档库。

这发生在ItemUpdated 上,当 doc 或 pdf 文件不在库中但创建它们并且我必须更新它们时,代码可以正常工作。

 ex = {"The file \"http://www-mylab.com/en/home/Documents/James-bond_1033.pdf\" is not checked out.  You must first check out this document before making changes."}

   web.Files.Add(wordFileUrl, wordStream, true);

【问题讨论】:

    标签: sharepoint document event-receiver


    【解决方案1】:

    在您的document library versioning settings 上最容易打开“需要结帐”设置。

    否则您将不得不调用 SharePoint Lists webserviceCheckInFileCheckOutFile 成员。

    【讨论】:

    • 如问题所示,如果您使用服务器对象模型,则无需 web 服务。 SPFile f = web.GetFile(wordFileUrl); f.CheckOut(); 应该可以解决问题。
    • 是的,需要更多信息,因为问题不建议我使用 SharePoint OM...在这种情况下,需要更多帮助。跨度>
    • Web.Files.Add(url,stream,boolean) 看起来不像 msdn.microsoft.com/en-us/library/ms412937(v=office.12).aspx 吗?
    【解决方案2】:

    看起来您正在使用 SharePoint 的服务器对象模型。

    SPFile f = web.GetFile(wordFileUrl); 
    f.CheckOut(); 
    
    web.Files.Add(wordFileUrl, wordStream, true);
    
    f.Checkin("new version");
    

    应该做的伎俩

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-17
      • 1970-01-01
      相关资源
      最近更新 更多