Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Proggramtically working with Doc library through event handler...

  Asked By: Anushka    Date: Feb 04    Category: Sharepoint    Views: 1206

I would like to add a event handler on a document list, but am having
some issues determining how to access the list item that fired the
event.

It is an added event.

What i would like to do it is read the text file that gets uploaded,
and programmatically create a new file, and move the file to a
different document library.

Can anyone help with code snippets to get me started on this?

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Bhairavi Damle     Answered On: Feb 04

I don't have any specific code  fragments to offer right now, but if you take a
look at the properties object passed to the event  as a parameter you will find a
number of properties that will be useful. For example, the list  and item  that
fired the event are included. You can use these properties to instantiate the
list and file  that you want to read.

 
Answer #2    Answered By: Leeann Hull     Answered On: Feb 04

i can access  all the file  properties now
thanks to you.

Any suggestions on how to read  the file. I can only seem to open it
as a binsayr strema but not a text  file.

Any ideas?

 
Answer #3    Answered By: Vaasu Radhakrishna     Answered On: Feb 04

It looks like there's a ListItem property off of the
SPItemEventProperties object that's passed-in.

I overrode the ItemAdded event  and was able to copy the file  as follows.

public override void ItemAdded(SPItemEventProperties properties)
{
properties.ListItem.File.CopyTo("Shared Documents");
}

This didn't do exactly what I wanted...it created a text  document
called "Shared Documents" (because I'm a dufus and didn't have Shared
Document list), but maybe this will point you in the right direction
(i.e. There's a ListItem property and a File for document  libraries off
of the ListItem property).

 




Tagged: