MsProject技术交流群207637602

ListItem Updating事件监视有没有上传附件

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using System.Web;

namespace MyProject.Features
{
    public class MyEventReceiver : SPItemEventReceiver
    {
        HttpContext currentContext;

        public MyEventReceiver()
        {
            currentContext = HttpContext.Current;
        }
       
        public override void ItemAdding(SPItemEventProperties properties)
        {            
  if (currentContext != null)
        {
          if (currentContext.Request.Files.Count > 0)
          {

            // there are attachments

          }
   else
   {

            // there are no attachments

   }
        }                           
        }
     }
}

  我之前也以为能用item.Attachment.count去监视,后来发现这个时候都还是正在更新,并不能监视此时有没有附件。

所以用HttpContext.Current;来监视是最好的,因为它可以监视上传流。

posted @ 2013-07-19 17:24  鳄鱼的眼泪  阅读(266)  评论(0编辑  收藏  举报

专业MSProject,QQ411033149