我原来传了个文件上来,现在又修改了下,请问我代码里如何判断这个文件已经被修改过了呢?
------解决方案--------------------
ItemUpdating%ItemUpdated
------解决方案--------------------
1.比较修改时间
2.添加Item更新的EventHanlder,就可以对Item的更新进行监控了当你的Item更新的时候就会触发楼上说的ItemUpdating和ItemUpdated事件。
------解决方案--------------------
可以使用EventHanlder来监控
给你一段示例代码以供参考
- C# code
using System; using System.Collections.Generic; using System.Text; 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(); } } } }
------解决方案--------------------
很简单,因为一个文件在sharepoint中对应一个SPListItem.
只要比较Item["Created"]和Item["Modified"]是否相同就可以了。