【问题标题】:Move SharePoint list items into folders that exists in the same list programmatically?以编程方式将 SharePoint 列表项移动到存在于同一列表中的文件夹中?
【发布时间】:2014-09-04 01:50:00
【问题描述】:

尊敬的 StackOverflow 成员,请帮助我提出解决问题的建议。

我在 SharePoint 列表中有 +20,000 个项目,我想将这些项目移动到同样存在于同一列表中的文件夹中。我想根据它们的创建日期移动它们。

例如:2013 年 7 月 7 日创建的项目应移至 2013 年文件夹 --> 7 月 2013 年 12 月 10 日创建的项目应移动到文件夹 2013 --> 12 月

我想使用 C# 代码执行此操作。如果没有,我也可以使用 PowerShell 脚本。

请分享您对此的看法。这对我来说将是一个高度优先的问题。

问候,

【问题讨论】:

标签: c# powershell sharepoint sharepoint-2010


【解决方案1】:
【解决方案2】:

以下代码可能会对您有所帮助:)

SPListItemCollection collListItems = oDocumentLibrary.Items;

                        foreach (SPListItem oListItem in collListItems)
                        {
                            if (oListItem.File != null)
                            {
                                if ((DateTime.Now - oListItem.File.TimeCreated).TotalDays <= 100)
                                {
                                    temp_date_Created = oListItem.File.TimeCreated;
                                    if (temp_date_Created >= date_Created)
                                    {
                                        date_Created=temp_date_Created;
                                         file_url = oListItem.Url;

                                    }

                                }


                            }


                        }

【讨论】:

  • 以上逻辑查找从当前日期起 100 天内创建的文件
猜你喜欢
  • 2016-07-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-10-13
  • 2011-01-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多