While the ItemUpdating event should fire before any data is comitted to the
database, the following event handler acts somewhat strange.
I'm trying to create a handler that, when a user overwrites an existing file
in a document library, will put the overwritten file in the recycle bin
before saving the new file:
public override void ItemUpdating(SPItemEventProperties properties)
{
RecycleFile(properties);
}
void RecycleFile(SPItemEventProperties properties)
{
SPWeb web = properties.OpenWeb(); // Open current web
SPFile file = web.GetFile(properties.AfterUrl); // Get existing
file
if (file.Exists) // If a file exits
{
file.Recycle(); // Recycle it!
}
}
After this code is run, the new file should be saved, but what happens is
that the existing file is deleted and the new file is newer saved. Can anyone
tell me why?
Thanks!
Kalmberg
Just a thought.
"Kalmberg" <kalm...@newsgroups.nospam> wrote in message
news:1D7E72DD-D8AE-4729...@microsoft.com...
I'm facing the same issue as below. Have you found any resolution of this? If yes, please share the same.
kalmber wrote:
ItemUpdating event handler
29-Nov-07
Hi all!
Thanks!
Kalmberg
Previous Posts In This Thread:
On Thursday, November 29, 2007 4:46 AM
kalmber wrote:
ItemUpdating event handler
Hi all!
Thanks!
Kalmberg
On Saturday, December 01, 2007 6:00 AM
jerome_vuiber wrote:
If you delete the file, then ItemDeleted or ItemDeleting wan be used
If you delete the file, then ItemDeleted or ItemDeleting wan be used
On Sunday, December 02, 2007 7:37 PM
JD wrote:
I do not know, but have you tried calling DisableEventFiring at the beginning
I do not know, but have you tried calling DisableEventFiring at the
beginning of your RecycleFile function and EnableEventFiring at the end?
Just a thought.
Submitted via EggHeadCafe - Software Developer Portal of Choice
JavaScript Distributed Slider Weight Control
http://www.eggheadcafe.com/tutorials/aspnet/777a843c-9bb4-44b3-8ae4-b693cbe57376/javascript-distributed-sl.aspx