您可以修改 Sharepoint 2010 文档上的“创建日期”属性吗?

发布于 2024-09-07 12:09:07 字数 205 浏览 18 评论 0原文

我正在将我们公司的文档从通用文件服务器迁移到 Sharepoint 2010,并且想知道是否有任何方法可以保留文档中的原始“创建日期”属性,以便它在 Sharepoint 中显示为原始创建日期而不是日期它已添加到 Sharepoint。这可能吗?目前,我们正在自定义迁移程序中使用 Sharepoint 的 Web 服务,将所有文档从文件服务器添加到 Sharepoint,同时添加一些元数据值。

I'm working on migrating our company's documents from a generic file server to Sharepoint 2010 and was wondering if there was any way to keep the original Created Date property from the documents so it shows up in Sharepoint with the original Creation date rather than the date it was added to Sharepoint. Is this possible? We're currently using Sharepoint's web services in a custom migration program to add all the documents to Sharepoint from the file server, while adding some metadata values along the way.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谜兔 2024-09-14 12:09:07

使用标准 Web 服务是不可能的,但您可以使用如下方法编写自己的 WS:

[WebMethod]
public void FixFileData(string fileUrl, DateTime created, DateTime modified, string author, string editor)
{
  Guid siteId = SPContext.Current.Site.ID;
  Guid webId = SPContext.Current.Web.ID;
  try
  {
    SPSecurity.RunWithElevatedPrivileges(delegate
    {
      using (SPSite site = new SPSite(siteId))
      {
        using (SPWeb web = site.OpenWeb(webId))
        {
          SPFile file = web.GetFile(fileUrl);
          SPListItem fileItem = file.Item;
          fileItem[SPBuiltInFieldId.Created] = SPUtility.CreateISO8601DateTimeFromSystemDateTime(created.ToUniversalTime());
          fileItem[SPBuiltInFieldId.Modified] = SPUtility.CreateISO8601DateTimeFromSystemDateTime(modified.ToUniversalTime());
          try
          {
            fileItem[SPBuiltInFieldId.Author]=web.EnsureUser(author);
          }
          catch (Exception)
          {
          // Your loggin code
          }
          try
          {
            fileItem[SPBuiltInFieldId.Editor] = web.EnsureUser(editor);
          }
          catch (Exception)
          {
          // Your loggin code
          }
          fileItem.UpdateOverwriteVersion();
          if (fileItem.ParentList.EnableMinorVersions)
          {
            file.Publish("SPFileUpload");
          }
          if (fileItem.ModerationInformation != null)
          {
            file.Approve("SPFileUpload");
          }
        }
      }
    });
  }
  catch (Exception)
  {
  // Your loggin code
  }
}

It's not possible using the Standard WebServices, but you could write your own WS with a method like this:

[WebMethod]
public void FixFileData(string fileUrl, DateTime created, DateTime modified, string author, string editor)
{
  Guid siteId = SPContext.Current.Site.ID;
  Guid webId = SPContext.Current.Web.ID;
  try
  {
    SPSecurity.RunWithElevatedPrivileges(delegate
    {
      using (SPSite site = new SPSite(siteId))
      {
        using (SPWeb web = site.OpenWeb(webId))
        {
          SPFile file = web.GetFile(fileUrl);
          SPListItem fileItem = file.Item;
          fileItem[SPBuiltInFieldId.Created] = SPUtility.CreateISO8601DateTimeFromSystemDateTime(created.ToUniversalTime());
          fileItem[SPBuiltInFieldId.Modified] = SPUtility.CreateISO8601DateTimeFromSystemDateTime(modified.ToUniversalTime());
          try
          {
            fileItem[SPBuiltInFieldId.Author]=web.EnsureUser(author);
          }
          catch (Exception)
          {
          // Your loggin code
          }
          try
          {
            fileItem[SPBuiltInFieldId.Editor] = web.EnsureUser(editor);
          }
          catch (Exception)
          {
          // Your loggin code
          }
          fileItem.UpdateOverwriteVersion();
          if (fileItem.ParentList.EnableMinorVersions)
          {
            file.Publish("SPFileUpload");
          }
          if (fileItem.ModerationInformation != null)
          {
            file.Approve("SPFileUpload");
          }
        }
      }
    });
  }
  catch (Exception)
  {
  // Your loggin code
  }
}
一场信仰旅途 2024-09-14 12:09:07

如果它是 2010 发布站点,则您可以使用站点菜单下的管理内容链接来复制或移动文件,它将保留文件系统属性,包括创建者、创建者、修改者和修改者。修改者。

If it's a 2010 Publishing site then you can use the Manage Content link under the Site Menu to copy or move files and it will preserve the file system attributes, including Created, Created By, Modified & Modified By.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文