通过编程方式在SharePoint 2010文档库中进行签入签出操作
本文中你将看到一个如何通过编程方式在SharePoint 2010文档库中签入和签出一个或多个文档例子。
我创建了一个控制台应用程序来完成该任务。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace CheckinCheckoutDemo
{
class MyDemo
{
static void Main(string[] args)
{
using (SPSite site = new SPSite(“http://SPSite”))
{
using (SPWeb web = site.OpenWeb())
{
SPDocumentLibrary docs = (SPDocumentLibrary)web.Lists["Mydocumentlibrary"]; -> Your Document library name
foreach (SPFile file in docs.RootFolder.Files)
{
if (file.CheckOutType == SPFile.SPCheckOutType.None)
{
file.CheckOut(); -> Checking out the file
}
}
// Getting the above Checked Out file.
foreach (SPCheckedOutFile file in docs.CheckedOutFiles)
{
Console.WriteLine(file.LeafName); -> Writing names of checked out files
}
// Check in and add a comment.
foreach (SPFile file in docs.RootFolder.Files)
{
if (file.CheckOutType != SPFile.SPCheckOutType.None)
{
file.CheckIn(“Programmatically Checked In”); -> checking In and adding a comment
}
}}}
参考资料
Programmatically Check in\Check out documents in SharePoint 2010
浙公网安备 33010602011771号