Event Handler的开发与部署2

1、首先打开Microsoft Visual Studio 2005,创建一个Class Library的项目,取名为Eallies.EventHandler.Demo。Event Handler的开发与部署2

 

 

2、创建项目成功后,将默认的Class1.cs改名为DocumentHandler.cs,并添加Microsoft.SharePoint.dll的引用,该DLL的具体位置在C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI。

 3、编写DocumentHandler.cs的代码

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Xml;

using Microsoft.SharePoint;

using System.IO;

namespace Eallies.EventHandler.Demo

{

    public class DocumentHandler : IListEventSink

    {

        public void OnEvent(SPListEvent list)

        {

             if (list.Type == SPListEventType.Insert)

             {

                 string path = @"c:\DocumentHandler.txt";

                 string text = "Insert" + "-" + DateTime.Now.ToString();

                 StreamWriter writer = new StreamWriter(path);

                 writer.Write(text);

                 writer.Close();

             }

        }

    }

}

4、将项目的输出目录更改为C:\Inetpub\wwwroot\wss\VirtualDirectories\9001\_app_bin。

Event Handler的开发与部署2

5、为项目创建一个强名称。

Event Handler的开发与部署2

 

 

你可能感兴趣的:(handler)