SharePoint 2013/2010 在一个列表或文档库内移动列表项,文档和目录位置而保持last modify by 等系统字段保持不变
本文讲述SharePoint 2013/2010 在一个列表或文档库内移动列表项。文档和目录位置而保持last modify by 等系统字段保持不变的解决方式。
近期遇到客户一个需求,在一个列表或文档库内移动列表项,文档和目录位置而保持last modify by 等系统字段保持不变。
研究出来了。不敢独享。特此共享出来给同鞋们做參考:
- using Microsoft.SharePoint;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MoveSPListItemTool
- {
- class Program
- {
- static void Main(string[] args)
- {
- SPSecurity.RunWithElevatedPrivileges(delegate()
- {
- using (SPSite site = new SPSite("http://SP2013/"))
- {
- site.AllowUnsafeUpdates = true;
- using (SPWeb web = site.OpenWeb())
- {
- SPList list = web.Lists["Documents"];
- var itemNeedToMove = list.GetItemById(7);
- MoveItemTo(itemNeedToMove, "TestDocumentSet");
- }
- }
- });
- Console.WriteLine("Done!");
- Console.ReadKey();
- }
- // Path 參数实例: Folder1, Folder1/Folder2
- public static void MoveItemTo(SPListItem item, string path)
- {
- switch (item.FileSystemObjectType)
- {
- case SPFileSystemObjectType.Folder:
- var newFolder = string.Format("{0}/{1}/{2}", item.ParentList.RootFolder.Url, path, item.Folder.Name);
- item.Folder.MoveTo(newFolder);
- break;
- case SPFileSystemObjectType.File:
- if (item.File == null)
- {
- var file = item.Web.GetFile(item.Url);
- var newFilePath = string.Format("{0}/{1}/{2}_.000", item.ParentList.RootFolder.Url, path, item.ID);
- file.MoveTo(newFilePath);
- }
- else
- {
- var file = item.Web.GetFile(item.Url);
- var newFilePath = string.Format("{0}/{1}/{2}", item.ParentList.RootFolder.Url, path, item.File.Name);
- file.MoveTo(newFilePath);
- }
- break;
- }
- }
- }
- }
SharePoint 2013/2010 在一个列表或文档库内移动列表项,文档和目录位置而保持last modify by 等系统字段保持不变的更多相关文章
- SharePoint 2013/2010 中的日历重合 (Calendars Overlay)
本文介绍 SharePoint 2013/2010 中的日历重合 (Calendars Overlay). 日历重合 (Calendars Overlay)的用途就是将 不多于10个日历或日历视图聚集 ...
- 如何在 在SharePoint 2013/2010 解决方案中添加 ashx (HttpHandler)
本文讲述如何在 在SharePoint 2013/2010 解决方案中添加 ashx (HttpHandler). 一般处理程序(HttpHandler)是·NET众多web组件的一种,ashx是其扩 ...
- 每天的学习经验:SharePoint 2013 定义自己添加的产品清单。Callout菜单项、文档关注、SharePoint服务机端对象模型查询
前言: 前一段时间一直都比較忙.没有什么时间进行总结,刚好节前项目上线.同一时候趁着放假能够好好的对之前遇到的一些问题进行总结. 主要内容有使用SharePoint服务端对象模型进行查询.为Share ...
- Sharepoint 2013/2010 登陆身份验证
SharePoint 2013 and SharePoint 2010登陆身份验证格式: <IdentityClaim>:0<ClaimType><ClaimValueT ...
- SharePoint 2013在浏览器中打开pdf文档
在没有安装Office Web Apps的情况下,SharePoint 2013是支持在IE上直接打开pdf和Excel文档的(只能查看,不能编辑,部分Excel会报错). 当然,需要现在管理中心做一 ...
- SharePoint 2013功能(SPFeature)与GUID对照表
自从上次遇到了一些无法开启SharePoint功能的事件之后(详见<SharePoint 2013 托管导航无法被开启的解决办法>一文),对于在SharePoint中所提示的GUID就格外 ...
- SharePoint 2013 跨网站集发布功能简介
在SharePoint Server 2013网站实施中,我们经常会遇到跨网站集获取数据,而2013的这一跨网站集发布功能,正好满足我们这样的需求. 使用SharePoint 2013中的跨网站发布, ...
- SharePoint 2013的100个新功能之开发
一:SharePoint应用 SharePoint 2013引入了云应用模型来供用户创建应用.SharePoint应用是独立的功能整合,扩展了SharePoint网站的功能.应用可以包含SharePo ...
- 每日学习心得:SharePoint 2013 自定义列表项添加Callout菜单项、文档关注、SharePoint服务端对象模型查询
前言: 前一段时间一直都比较忙,没有什么时间进行总结,刚好节前项目上线,同时趁着放假可以好好的对之前遇到的一些问题进行总结.主要内容有使用SharePoint服务端对象模型进行查询.为SharePoi ...
随机推荐
- 区别原生chrome 和以chrome为内核的360浏览器
function isChrome360() { if( navigator.userAgent.toLowerCase().indexOf('chrome') > -1 ) { var des ...
- Postman---html中get和post的区别和使用
get和post的区别和使用 Html中post和get区别,是不是用get的方法用post都能办到? Http定义了与服务器交互的不同方法,最基本的方法有4种,分别是GET,POST,PUT,DEL ...
- 【学习笔记】C#中的单元测试
周一老师讲完单元测试以后,感觉挺好玩,通过查资料和相关书籍学到了几种C#在VS2010的测试方法,跟大家分享下,图文并茂啊,有木有~~ 1.从被测试的代码中生成单元测试 1.1创建C#控制台程序,命名 ...
- TI博客文章-4-20mA电流环路发送器入门
TI博客文章-4-20mA电流环路发送器入门http://bbs.21ic.com/forum.php?mod=viewthread&tid=1610834&fromuid=10995 ...
- redis安装和配置(一)
Redis 的官方下载站是http://redis.io/download 怎么安装 Redis 数据库呢?下面将介绍Linux 版本的安装方法 步骤一: 下载Redis 下载安装包:wget htt ...
- struts和spring整合
开发流程: 1)引jar包,可以在配置工程中设置用户libarary,然后直接引入.如果在web-inf/lib没有用户导入的lib文件,可以参考问题0的解决方案 需要的是struts_core,sp ...
- spring boot下WebSocket消息推送(转)
原文地址:https://www.cnblogs.com/betterboyz/p/8669879.html WebSocket协议 WebSocket是一种在单个TCP连接上进行全双工通讯的协议.W ...
- 设置phpcms v9黄页模块作为首页方法
如果我们根据需要,想把黄页作为单独的网站,我们可以用模块化安装,并且首页设置,那么仿站网就说说详细的步骤.首先,我们需要安装最新版本的phpcms V9其次,下载黄页模块,然后进行根目录的替换.再次, ...
- C# 执行多条SQL更新语句,实现数据库事务
class Program { class Result<T> { public T data; public string Message; public bool Success; p ...
- makefile之findstring函数
#$(findstring <find>,<in> ) #功能:在字串<in>中查找<find>字串. #返回:如果找到,那么返回<find> ...