简体   繁体   English

通过编程将SharePoint列表项移动到同一列表中存在的文件夹中?

[英]Move SharePoint list items into folders that exists in the same list programmatically?

Respected members of StackOverflow, kindly help me with your kind suggestions to solve the issue. 尊敬的StackOverflow成员,请帮助我提供解决问题的建议。

I have +20,000 items in a SharePoint list that i want to move into the folders that also exists in the same list. 我想将SharePoint列表中的+20,000个项目移到同一列表中也存在的文件夹中。 I would like to move them according to their created date. 我想根据创建日期移动它们。

For example: Items created on 07-07-2013 should be moved to Folder 2013 --> July Items created on 12-10-2013 should be moved to Folder 2013 --> December 例如:在2013年7月7日创建的项目应移至文件夹2013->七月在2013年12月10日创建的项目应移至文件夹2013-> 12月

I would like to do this using C# code. 我想使用C#代码执行此操作。 If not, i can go with PowerShell script too. 如果没有,我也可以使用PowerShell脚本。

Kindly share your thoughts on it. 请分享您的想法。 It going to be an high priority issue for me. 对我来说,这将是一个高度优先的问题。

Regards, 问候,

following code may help you :) 以下代码可以帮助您:)

SPListItemCollection collListItems = oDocumentLibrary.Items; 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;

                                    }

                                }


                            }


                        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM