tags:

views:

1399

answers:

4

I'd like to inspect the content of a file before it is uploaded to the SharePoint doc library.
I hooked up a handler to the ItemAdding() event but don't know how to get the content of the file.
Note: I know that in the ItemAdded() I can use properties.ListItem.File but that's too late.

Thanks in advance.

+2  A: 

Yes, the file has not been created at this point.

Try using the properties.AfterProperties or properties.BeforeProperties.

Edit: It is only after the file has been added that the lists properties are created. SharePoint will add the defaults for the list metadata to the file (Office 2007 only) once the item has been created, but before the ItemAdded event. Bugger.

Nat
those are empty. but thanks.
vitule
+1  A: 

No you can't.
During ItemAdding, you have access to document/item properties as Nat said, but you don't have access to file content.

Nico
A: 

Will this AfterProperties be able to track the Workflow status of the item? I just wanted to fire an event only after the item has been approved.

Workflow Aproved status cant be seen in ItemAdded Event right? Does the ItemUpdated event gives? Where can i catch this status , in which event?

A: 

Do you know how to access the "Name" field of the uploaded file? On the adding or added method.

This code results on a null reference to an object:

ItemAdding: string name = properties.AfterProperties["Name"].ToString();

Any help will be greatly appreciated!