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 ...
随机推荐
- hibernate session的load和get方法
@Test public void testLoad() { Session session = sessionFactory.getCurrentSession(); session ...
- Java 内存区域和GC机制(转载)
目录 Java垃圾回收概况 Java内存区域 Java对象的访问方式 Java内存分配机制 Java GC机制 垃圾收集器 Java垃圾回收概况 Java GC(Garbage Collection, ...
- C++14系列(1):Linux下C++14开发环境配置
g++安装 參考地址: http://sysads.co.uk/2014/07/install-gcc-gnu-4-9-1-on-ubuntu-14-04/ 当前Ubuntu的LTS版本号为14.04 ...
- 【微信小程序】loading标签使用,可自定义时长
前言:loading和wx.showToast的区别: wx.showToast加载的时间长度是需要手动设置的,默认1500ms,而loading标签则可以配合数据加载进行隐藏. 核心就是在数据量较大 ...
- 为Drupal7.22添加富编辑器 on Ubuntu 12.04
怀揣着为中小企业量身定做一整套开源软件解决方案的梦想开始了一个网站的搭建.http://osssme.org/ 基本上就是按照Drupal7宝典里描述的进行设置的. 1. 下载wysiwyg 2. ...
- SQL外键约束
1.查询表已有的外键 select name from sys.foreign_key_columns f join sys.objects o on f.constraint_object_id=o ...
- 使用结构(C# 编程指南)
struct 类型适于表示 Point.Rectangle 和 Color 等轻量对象. 尽管使用自动实现的属性将一个点表示为类同样方便,但在某些情况下使用结构更加有效. 例如,如果声明一个 1000 ...
- Linux 基础学习(第二节)
free命令用于显示当前系统中内存的使用量信息,格式为:“free [-h]”. 为了保证Linux系统不会突然卡住宕机,因此内存使用量应该是运维人员时刻要关注的数据啦,咱们可以使用-h参数来以更人性 ...
- js 判断是否为mac电脑 、还是windows操作系统
/** * 是否为mac系统(包含iphone手机) * */ var isMac = function() { return /macintosh|mac os x/i.test(navigator ...
- Atitit..css的体系结构
Atitit..css的体系结构 1. Oocss 与 bem标准化1 1.1. 四种样式表及六种选择器1 1.2. 常用的css框架 amazeui bootstrap1 1.3. Css图标 ...