0

我想在列表项中捕获附件以检查文件长度及其扩展名。我创建了一个 SPItemEventReceiver 类,并重写了 SPItemEventReceiver.ItemAttachmentAdding 方法。但是,添加附件时不会触发该事件。

这个事件什么时候触发?如何检查文件长度和扩展名?

我的 EventHandler 类:

public class EventReceiver : SPItemEventReceiver
{
   /// <summary>
   /// An attachment is being added to the item.
   /// </summary>
   public override void ItemAttachmentAdding(SPItemEventProperties properties)
   {

       //some code here

       base.ItemAttachmentAdding(properties);
   }
}

我的元素.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers ListTemplateId="100">
      <Receiver>
        <Name>EventReceiverItemAttachmentAdding</Name>
        <Type>ItemAttachmentAdding</Type>
        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
        <Class>EventReceiver.EventReceiver</Class>
        <SequenceNumber>10000</SequenceNumber>
      </Receiver>
  </Receivers>
</Elements>
4

0 回答 0