c# - How do you get file details in a SharePoint ItemEventReciever in the ItemAdding Event? -
I would expect something like this to work but ListItem, BeforeProperties, AfterProperties all null / empty. I file names and file contents need
< P> I can not use ItemAdded as it is asynchronous and i need to be synchronous, i stop uploading and send message to user Can be shown. public class MyItemEventReceiver :.) SPItemEventReceiver {public MyItemEventReceiver ({} public override void ItemAdding (SPItemEventProperties properties) {SPListItem items = properties.ListItem; Bool fail = item.File.Name.Equals ( "fail.txt"); If (fail) {properties.ErrorMessage = "file failure is valid"; Properties.Cancel = true;}}}
For example would appreciate any suggestions, what is possible to override Upload.aspx?
you must have the files uploaded which can use the HttpContext to retrieve HttpFileCollection. it will only work to upload personal files through the web UI multiple file Uploading, or saving directly from the office, will not create an HttpContext. Try something like this:
Private HttpContext reference; Public MyItemEventReceiver () {Reference = HttpContext.Current; } Adding overhead zeros (SPItemEventProperties properties) {HttpFileCollection store = context.Request.Files; Foreach (collection string Namkkas) {if (archive [name] .contentLength & gt; 0) {// you need to do with the collection [name] .InputStream}}}
Comments
Post a Comment