VS2010 直接 右键解决方案 部署 EventHandler。 GAC里面也有相应的DLL了。但是运行程序无效果。
代码如下,不知道代码是否有问题。。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using System.IO;
namespace abc
{
public class TestEventHandle : SPItemEventReceiver
{
public override void ItemAdded(SPItemEventProperties properties)
{
try
{
SaveLog();
}
catch (Exception ex)
{
properties.ErrorMessage = ex.Message;
properties.Cancel = true;
}
}
public void SaveLog()
{
string path = @"c:\Log.txt";
string text = "Item" + ":" + DateTime.Now.ToString();
StreamWriter writer = new StreamWriter(path);
writer.Write(text);
writer.Close();
}
}
}
在List里面添加了一行数据,但并未在C盘生成相应文件。
sharepoint